Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Some INT and FLOAT alias conversions are illogical #19197

Closed
jseldess opened this issue Oct 11, 2017 · 1 comment · Fixed by #20798
Closed

sql: Some INT and FLOAT alias conversions are illogical #19197

jseldess opened this issue Oct 11, 2017 · 1 comment · Fixed by #20798
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@jseldess
Copy link
Contributor

~/Desktop$ cockroach version
Build Tag:    v1.1.0-rc.1-6-gf3937172b
Build Time:   2017/10/08 20:14:21
Distribution: CCL
Platform:     darwin amd64
Go Version:   go1.9
C Compiler:   4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)
Build SHA-1:  f3937172b903a1884ac9e01a2168de7c41908839
Build Type:   development

Currently, INT8 and INT64 convert to BIGINT, but BIGINT converts to INT:

root@:26257/> create table test.t3 (a int, b integer, c int8, d int64, e bigint, f int2, g smallint);
CREATE TABLE

Time: 7.096365ms

root@:26257/> show create table test.t3;
+---------+----------------------------------------------------+
|  Table  |                    CreateTable                     |
+---------+----------------------------------------------------+
| test.t3 | CREATE TABLE t3 (␤                                 |
|         |     a INT NULL,␤                                   |
|         |     b INTEGER NULL,␤                               |
|         |     c BIGINT NULL,␤                                |
|         |     d BIGINT NULL,␤                                |
|         |     e INT NULL,␤                                   |
|         |     f SMALLINT NULL,␤                              |
|         |     g SMALLINT NULL,␤                              |
|         |     FAMILY "primary" (a, b, c, d, e, f, g, rowid)␤ |
|         | )                                                  |
+---------+----------------------------------------------------+
(1 row)

Also, FLOAT4 converts to DOUBLE PRECISION, but DOUBLE PRECISION converts to FLOAT:

root@:26257/> create table test.floats (a float, b real, c double precision, d float4, e float8);
CREATE TABLE

Time: 6.350415ms

root@:26257/> show create table test.floats;
+-------------+----------------------------------------------+
|    Table    |                 CreateTable                  |
+-------------+----------------------------------------------+
| test.floats | CREATE TABLE floats (␤                       |
|             |     a FLOAT NULL,␤                           |
|             |     b REAL NULL,␤                            |
|             |     c FLOAT NULL,␤                           |
|             |     d REAL NULL,␤                            |
|             |     e DOUBLE PRECISION NULL,␤                |
|             |     FAMILY "primary" (a, b, c, d, e, rowid)␤ |
|             | )                                            |
+-------------+----------------------------------------------+
(1 row)
@jseldess jseldess added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Oct 11, 2017
@jordanlewis
Copy link
Member

@m-schneider could you please take a look at this? I think it should be a simple fix, probably.

@nvanbenschoten nvanbenschoten self-assigned this Dec 18, 2017
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this issue Dec 18, 2017
Fixes cockroachdb#19197.

This change cleans up the `coltype` to `VisibleType` alias mapping and adds
an alias for `coltype.BigInt -> VisibleType.BIGINT`.

The `coltypes.Double -> VisibleType.DOUBLE_PRECISION` mapping referenced in
the associated issue was already addressed during some previous refactor.

Release note (bug fix): The BIGINT type alias is now correctly shown
when using SHOW CREATE TABLE.
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this issue Dec 18, 2017
Fixes cockroachdb#19197.

This change cleans up the `coltype` to `VisibleType` alias mapping and adds
an alias for `coltype.BigInt -> VisibleType.BIGINT`.

The `coltypes.Double -> VisibleType.DOUBLE_PRECISION` mapping referenced in
the associated issue was already addressed during some previous refactor.

Release note (bug fix): The BIGINT type alias is now correctly shown
when using SHOW CREATE TABLE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants