Skip to content

Commit

Permalink
Merge pull request cockroachdb#16548 from m-schneider/int4
Browse files Browse the repository at this point in the history
sql: Adding support for integral aliases.
  • Loading branch information
Masha Schneider authored Jun 26, 2017
2 parents dfbb4fd + 91e87da commit ae0872a
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 153 deletions.
13 changes: 6 additions & 7 deletions pkg/sql/logictest/testdata/logic_test/show_trace
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ SELECT span, operation, message FROM [SHOW KV TRACE FOR CREATE TABLE t.kv(k INT
(0,1) starting plan querying next range at /System/"desc-idgen"
(0,1) starting plan r1: sending batch 1 Inc, 1 BeginTxn to (n1,s1):1
(0,1) starting plan CPut /Table/2/1/51/"kv"/3/1 -> 52
(0,1) starting plan CPut /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:1 up_version:false modification_time:<wall_time:0 logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:2 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" >
(0,1) starting plan CPut /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:1 up_version:false modification_time:<wall_time:0 logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:2 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" >
(0,1) starting plan querying next range at /Table/2/1/51/"kv"/3/1
(0,1) starting plan r1: sending batch 2 CPut to (n1,s1):1
(0,1) starting plan querying next range at /Table/3/1/51/2/1
Expand Down Expand Up @@ -109,7 +109,7 @@ SELECT span, operation, regexp_replace(regexp_replace(message, 'mutationJobs:<[^
(0,1) starting plan r1: sending batch 1 Get to (n1,s1):1
(0,1) starting plan querying next range at /Table/SystemConfigSpan/Start
(0,1) starting plan r1: sending batch 2 CPut, 1 BeginTxn to (n1,s1):1
(0,1) starting plan Put /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:1 up_version:true modification_time:<wall_time:... logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:3 privileges:<users:<user:"root" privileges:2 > > mutations:<index:<name:"woo" id:2 unique:true column_names:"v" column_directions:ASC column_ids:2 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > state:DELETE_ONLY direction:ADD mutation_id:1 resume_spans:<key:"\274\211" end_key:"\274\212" > > next_mutation_id:2 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" mutationJobs:<...> >
(0,1) starting plan Put /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:1 up_version:true modification_time:<wall_time:... logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:3 privileges:<users:<user:"root" privileges:2 > > mutations:<index:<name:"woo" id:2 unique:true column_names:"v" column_directions:ASC column_ids:2 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > state:DELETE_ONLY direction:ADD mutation_id:1 resume_spans:<key:"\274\211" end_key:"\274\212" > > next_mutation_id:2 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" mutationJobs:<...> >
(0,1) starting plan querying next range at /Table/3/1/52/2/1
(0,1) starting plan r1: sending batch 1 Put to (n1,s1):1
(0,1) starting plan querying next range at /Table/2/1/0/"system"/3/1
Expand Down Expand Up @@ -198,7 +198,7 @@ SELECT span, operation, regexp_replace(message, '\d\d\d\d\d+', '...PK...') as me
(0,1) starting plan querying next range at /System/"desc-idgen"
(0,1) starting plan r1: sending batch 1 Inc, 1 BeginTxn to (n1,s1):1
(0,1) starting plan CPut /Table/2/1/51/"kv2"/3/1 -> 53
(0,1) starting plan CPut /Table/3/1/53/2/1 -> table:<name:"kv2" id:53 parent_id:51 version:1 up_version:false modification_time:<wall_time:0 logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > columns:<name:"rowid" id:3 type:<semantic_type:INT width:0 precision:0 > nullable:false default_expr:"unique_rowid()" hidden:true > next_column_id:4 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_names:"rowid" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"rowid" column_directions:ASC column_ids:3 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:2 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" >
(0,1) starting plan CPut /Table/3/1/53/2/1 -> table:<name:"kv2" id:53 parent_id:51 version:1 up_version:false modification_time:<wall_time:0 logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > columns:<name:"rowid" id:3 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:false default_expr:"unique_rowid()" hidden:true > next_column_id:4 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_names:"rowid" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"rowid" column_directions:ASC column_ids:3 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:2 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" >
(0,1) starting plan querying next range at /Table/2/1/51/"kv2"/3/1
(0,1) starting plan r1: sending batch 2 CPut to (n1,s1):1
(0,1) starting plan querying next range at /Table/3/1/51/2/1
Expand Down Expand Up @@ -267,7 +267,7 @@ SELECT span, operation, message FROM [SHOW KV TRACE FOR DELETE FROM t.kv2]
query TTT
SELECT span, operation, message FROM [SHOW KV TRACE FOR DROP TABLE t.kv2] WHERE message NOT LIKE '%Z/%'
----
(0,1) starting plan Put /Table/3/1/53/2/1 -> table:<name:"kv2" id:53 parent_id:51 version:1 up_version:true modification_time:<wall_time:0 logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > columns:<name:"rowid" id:3 type:<semantic_type:INT width:0 precision:0 > nullable:false default_expr:"unique_rowid()" hidden:true > next_column_id:4 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_names:"rowid" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"rowid" column_directions:ASC column_ids:3 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:2 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:InterleavedFormatVersion state:DROP view_query:"" >
(0,1) starting plan Put /Table/3/1/53/2/1 -> table:<name:"kv2" id:53 parent_id:51 version:1 up_version:true modification_time:<wall_time:0 logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > columns:<name:"rowid" id:3 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:false default_expr:"unique_rowid()" hidden:true > next_column_id:4 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_names:"rowid" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"rowid" column_directions:ASC column_ids:3 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:2 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:InterleavedFormatVersion state:DROP view_query:"" >
(0,1) starting plan querying next range at /Table/SystemConfigSpan/Start
(0,1) starting plan r1: sending batch 1 Put, 1 BeginTxn to (n1,s1):1
(0,1) starting plan querying next range at /Table/2/1/0/"system"/3/1
Expand Down Expand Up @@ -326,7 +326,7 @@ SELECT span, operation, regexp_replace(regexp_replace(message, 'mutationJobs:<[^
(0,1) starting plan r1: sending batch 1 Get to (n1,s1):1
(0,1) starting plan querying next range at /Table/SystemConfigSpan/Start
(0,1) starting plan r1: sending batch 2 CPut, 1 BeginTxn to (n1,s1):1
(0,1) starting plan Put /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:4 up_version:true modification_time:<wall_time:... logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:3 privileges:<users:<user:"root" privileges:2 > > mutations:<index:<name:"woo" id:2 unique:true column_names:"v" column_directions:ASC column_ids:2 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > state:DELETE_AND_WRITE_ONLY direction:DROP mutation_id:2 resume_spans:<key:"\274\211" end_key:"\274\212" > > next_mutation_id:3 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" mutationJobs:<...> >
(0,1) starting plan Put /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:4 up_version:true modification_time:<wall_time:... logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:3 privileges:<users:<user:"root" privileges:2 > > mutations:<index:<name:"woo" id:2 unique:true column_names:"v" column_directions:ASC column_ids:2 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > state:DELETE_AND_WRITE_ONLY direction:DROP mutation_id:2 resume_spans:<key:"\274\211" end_key:"\274\212" > > next_mutation_id:3 format_version:InterleavedFormatVersion state:PUBLIC view_query:"" mutationJobs:<...> >
(0,1) starting plan querying next range at /Table/3/1/52/2/1
(0,1) starting plan r1: sending batch 1 Put to (n1,s1):1
(0,1) starting plan querying next range at /Table/2/1/0/"system"/3/1
Expand All @@ -345,7 +345,7 @@ query TTT
SELECT span, operation, regexp_replace(regexp_replace(message, 'mutationJobs:<[^>]*>', 'mutationJobs:<...>'), 'wall_time:\d+', 'wall_time:...') as message
FROM [SHOW KV TRACE FOR DROP TABLE t.kv] WHERE message NOT LIKE '%Z/%'
----
(0,1) starting plan Put /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:7 up_version:true modification_time:<wall_time:... logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:3 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:3 format_version:InterleavedFormatVersion state:DROP view_query:"" >
(0,1) starting plan Put /Table/3/1/52/2/1 -> table:<name:"kv" id:52 parent_id:51 version:7 up_version:true modification_time:<wall_time:... logical:0 > columns:<name:"k" id:1 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:false hidden:false > columns:<name:"v" id:2 type:<semantic_type:INT width:0 precision:0 visible_type:NONE > nullable:true hidden:false > next_column_id:3 families:<name:"primary" id:0 column_names:"k" column_names:"v" column_ids:1 column_ids:2 default_column_id:2 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true column_names:"k" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 > interleave:<> > next_index_id:3 privileges:<users:<user:"root" privileges:2 > > next_mutation_id:3 format_version:InterleavedFormatVersion state:DROP view_query:"" >
(0,1) starting plan querying next range at /Table/SystemConfigSpan/Start
(0,1) starting plan r1: sending batch 1 Put, 1 BeginTxn to (n1,s1):1
(0,1) starting plan querying next range at /Table/2/1/0/"system"/3/1
Expand Down Expand Up @@ -695,4 +695,3 @@ fetched: /abc/primary/1/'one' -> NULL
fetched: /abc/primary/1/'one'/c -> 1.1
fetched: /abc/primary/2/'two' -> NULL
fetched: /abc/primary/3/'three' -> NULL

4 changes: 2 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/table
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ SHOW COLUMNS FROM test.alltypes
Field Type Null Default Indices
a BOOL true NULL {}
b INT true NULL {}
c INT true NULL {}
d INT true NULL {}
c INT8 true NULL {}
d INT64 true NULL {}
e INT true NULL {}
f INT true NULL {}
g INT true NULL {}
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/sqlbase/structured.go
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,9 @@ func (c *ColumnType) SQLString() string {
case ColumnType_INT_ARRAY:
return "INT[]"
}
if c.VisibleType != ColumnType_NONE {
return c.VisibleType.String()
}
return c.SemanticType.String()
}

Expand Down
Loading

0 comments on commit ae0872a

Please sign in to comment.