Skip to content

Commit

Permalink
Merge #32831
Browse files Browse the repository at this point in the history
32831: sql: Make INT an alias for INT8 r=bobvawter a=bobvawter

This is the first in a series of changes to allow INT to eventually be
redefined as INT4.

Currently, a "naked" INT is generally treated as a 64-bit int type, but INT is
separate from INT8. This change eliminates INT as a distinct type in favor of
always using INT8. This is analogous to how we treat FLOAT/FLOAT8.

The coltypes.Int global has been removed and we should no longer produce type
objects that have a zero Width. The existing interpretation of zero-Width types
as 64-bit values will continue indefinitely to preserve backwards-compatibility
with existing descriptors.

In general, the changes to tests are due to the widespread use of INT as an
arbitary datatype. Except in a few cases where we are testing how "INT" is
interpreted as a datatype, the tests have been changed to simply use INT8, to
avoid another major round of text fixups as work on #26925 continues.

Release note (sql change): The INT type is now treated as an alias for INT8.

Co-authored-by: Bob Vawter <[email protected]>
  • Loading branch information
craig[bot] and bobvawter committed Dec 10, 2018
2 parents 8f30db0 + d333976 commit 8d30b87
Show file tree
Hide file tree
Showing 130 changed files with 2,492 additions and 2,342 deletions.
166 changes: 83 additions & 83 deletions pkg/ccl/importccl/import_stmt_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/ccl/importccl/read_import_pgdump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestPostgreStreamCopy(t *testing.T) {

const sql = `
CREATE TABLE public.second (
i integer NOT NULL,
i int8 NOT NULL,
s text
);
Expand Down Expand Up @@ -123,7 +123,7 @@ COPY public.t (s) FROM stdin;
}
fmt.Fprintf(&sb, "%s;\n", s)
}
const expect = `CREATE TABLE public.second (i INT NOT NULL, s STRING);
const expect = `CREATE TABLE public.second (i INT8 NOT NULL, s STRING);
COPY public.second (i, s) FROM STDIN;
"0" "0";
"1" "1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ query TT
SHOW CREATE TABLE p
----
p CREATE TABLE p (
a INT NOT NULL,
a INT8 NOT NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC),
FAMILY "primary" (a)
) PARTITION BY LIST (a) (
Expand Down
72 changes: 36 additions & 36 deletions pkg/ccl/logictestccl/testdata/logic_test/partitioning
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ query TT
SHOW CREATE TABLE ok1
----
ok1 CREATE TABLE ok1 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a) (
Expand All @@ -400,9 +400,9 @@ query TT
SHOW CREATE TABLE ok2
----
ok2 CREATE TABLE ok2 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a) (
Expand All @@ -420,9 +420,9 @@ query TT
SHOW CREATE TABLE ok3
----
ok3 CREATE TABLE ok3 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a) (
Expand All @@ -442,9 +442,9 @@ query TT
SHOW CREATE TABLE ok4
----
ok4 CREATE TABLE ok4 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a, b) (
Expand All @@ -470,9 +470,9 @@ query TT
SHOW CREATE TABLE ok5
----
ok5 CREATE TABLE ok5 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a) (
Expand All @@ -496,9 +496,9 @@ query TT
SHOW CREATE TABLE ok6
----
ok6 CREATE TABLE ok6 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY RANGE (a) (
Expand All @@ -515,9 +515,9 @@ query TT
SHOW CREATE TABLE ok7
----
ok7 CREATE TABLE ok7 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY RANGE (a) (
Expand All @@ -535,9 +535,9 @@ query TT
SHOW CREATE TABLE ok8
----
ok8 CREATE TABLE ok8 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY RANGE (a) (
Expand All @@ -558,9 +558,9 @@ query TT
SHOW CREATE TABLE ok9
----
ok9 CREATE TABLE ok9 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY RANGE (a, b) (
Expand All @@ -583,9 +583,9 @@ query TT
SHOW CREATE TABLE ok10
----
ok10 CREATE TABLE ok10 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY RANGE (a, b) (
Expand Down Expand Up @@ -613,9 +613,9 @@ query TT
SHOW CREATE TABLE ok11
----
ok11 CREATE TABLE ok11 (
a INT NOT NULL,
b INT NOT NULL,
c INT NOT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NOT NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC, c ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a) (
Expand All @@ -642,9 +642,9 @@ query TT
SHOW CREATE TABLE ok12
----
ok12 CREATE TABLE ok12 (
a INT NOT NULL,
b INT NOT NULL,
c INT NULL,
a INT8 NOT NULL,
b INT8 NOT NULL,
c INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC, b ASC),
FAMILY "primary" (a, b, c)
) PARTITION BY LIST (a) (
Expand Down
16 changes: 8 additions & 8 deletions pkg/ccl/logictestccl/testdata/logic_test/partitioning_index
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ query TT
SHOW CREATE TABLE ok1
----
ok1 CREATE TABLE ok1 (
a INT NOT NULL,
b INT NULL,
a INT8 NOT NULL,
b INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC),
INDEX ok1_b_idx (b ASC) PARTITION BY LIST (b) (
PARTITION p1 VALUES IN ((1)),
Expand All @@ -40,8 +40,8 @@ query TT
SHOW CREATE TABLE ok2
----
ok2 CREATE TABLE ok2 (
a INT NOT NULL,
b INT NULL,
a INT8 NOT NULL,
b INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC),
UNIQUE INDEX ok2_b_key (b ASC) PARTITION BY LIST (b) (
PARTITION p1 VALUES IN ((1))
Expand All @@ -61,8 +61,8 @@ query TT
SHOW CREATE TABLE ok3
----
ok3 CREATE TABLE ok3 (
a INT NOT NULL,
b INT NULL,
a INT8 NOT NULL,
b INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC),
UNIQUE INDEX ok3_b_key (b ASC) PARTITION BY LIST (b) (
PARTITION p1 VALUES IN ((1))
Expand Down Expand Up @@ -102,8 +102,8 @@ query TT
SHOW CREATE TABLE indexes
----
indexes CREATE TABLE indexes (
a INT NOT NULL,
b INT NULL,
a INT8 NOT NULL,
b INT8 NULL,
CONSTRAINT "primary" PRIMARY KEY (a ASC),
INDEX i1 (b ASC) PARTITION BY LIST (b) (
PARTITION p1 VALUES IN ((1))
Expand Down
10 changes: 5 additions & 5 deletions pkg/cli/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestDumpAsOf(t *testing.T) {

const create = `
CREATE DATABASE d;
CREATE TABLE d.t (i int);
CREATE TABLE d.t (i int8);
INSERT INTO d.t VALUES (1);
SELECT now();
`
Expand All @@ -397,7 +397,7 @@ func TestDumpAsOf(t *testing.T) {

const want1 = `dump d t
CREATE TABLE t (
i INT NULL,
i INT8 NULL,
FAMILY "primary" (i, rowid)
);
Expand All @@ -409,7 +409,7 @@ INSERT INTO t (i) VALUES
}

c.RunWithArgs([]string{"sql", "-e", `
ALTER TABLE d.t ADD COLUMN j int DEFAULT 2;
ALTER TABLE d.t ADD COLUMN j int8 DEFAULT 2;
INSERT INTO d.t VALUES (3, 4);
`})

Expand All @@ -419,8 +419,8 @@ INSERT INTO t (i) VALUES
}
const want2 = `dump d t
CREATE TABLE t (
i INT NULL,
j INT NULL DEFAULT 2:::INT,
i INT8 NULL,
j INT8 NULL DEFAULT 2:::INT8,
FAMILY "primary" (i, rowid, j)
);
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/sql_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ SET
}

expectedRows := [][]string{
{`parentID`, `INT`, `false`, `NULL`, ``, `{primary}`, `false`},
{`parentID`, `INT8`, `false`, `NULL`, ``, `{primary}`, `false`},
{`name`, `STRING`, `false`, `NULL`, ``, `{primary}`, `false`},
{`id`, `INT`, `true`, `NULL`, ``, `{}`, `false`},
{`id`, `INT8`, `true`, `NULL`, ``, `{}`, `false`},
}
if !reflect.DeepEqual(expectedRows, rows) {
t.Fatalf("expected:\n%v\ngot:\n%v", expectedRows, rows)
Expand All @@ -151,9 +151,9 @@ SET
expected = `
column_name | data_type | is_nullable | column_default | generation_expression | indices | is_hidden
+-------------+-----------+-------------+----------------+-----------------------+-----------+-----------+
parentID | INT | false | NULL | | {primary} | false
parentID | INT8 | false | NULL | | {primary} | false
name | STRING | false | NULL | | {primary} | false
id | INT | true | NULL | | {} | false
id | INT8 | true | NULL | | {} | false
(3 rows)
`

Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/testdata/dump/computed
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ dump d t
----
----
CREATE TABLE t (
a INT NOT NULL,
b INT NULL AS (a + 1) STORED,
a INT8 NOT NULL,
b INT8 NULL AS (a + 1) STORED,
CONSTRAINT "primary" PRIMARY KEY (a ASC),
FAMILY "primary" (a, b)
);
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/testdata/dump/flags
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dump t f --dump-mode=both
----
----
CREATE TABLE f (
x INT NULL,
y INT NULL,
x INT8 NULL,
y INT8 NULL,
FAMILY "primary" (x, y, rowid)
);

Expand All @@ -22,8 +22,8 @@ INSERT INTO f (x, y) VALUES
dump t f --dump-mode=schema
----
CREATE TABLE f (
x INT NULL,
y INT NULL,
x INT8 NULL,
y INT8 NULL,
FAMILY "primary" (x, y, rowid)
);

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/testdata/dump/identifiers
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dump d
----
----
CREATE TABLE ";" (
";" INT NULL,
";" INT8 NULL,
INDEX ";_;_idx" (";" ASC),
FAMILY "primary" (";", rowid)
);
Expand Down
16 changes: 8 additions & 8 deletions pkg/cli/testdata/dump/multiple
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ dump t f g
----
----
CREATE TABLE f (
x INT NULL,
y INT NULL,
x INT8 NULL,
y INT8 NULL,
FAMILY "primary" (x, y, rowid)
);

CREATE TABLE g (
x INT NULL,
y INT NULL,
x INT8 NULL,
y INT8 NULL,
FAMILY "primary" (x, y, rowid)
);

Expand All @@ -34,14 +34,14 @@ dump t
----
----
CREATE TABLE f (
x INT NULL,
y INT NULL,
x INT8 NULL,
y INT8 NULL,
FAMILY "primary" (x, y, rowid)
);

CREATE TABLE g (
x INT NULL,
y INT NULL,
x INT8 NULL,
y INT8 NULL,
FAMILY "primary" (x, y, rowid)
);

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/testdata/dump/primary_key
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dump d t
----
----
CREATE TABLE t (
i INT NOT NULL,
i INT8 NOT NULL,
CONSTRAINT pk_name PRIMARY KEY (i ASC),
FAMILY "primary" (i)
);
Expand Down
Loading

0 comments on commit 8d30b87

Please sign in to comment.