Skip to content

Commit

Permalink
sql: Added SELECT query and CTAS timestamp fields to TableDescriptor
Browse files Browse the repository at this point in the history
CTAS was initially planned and executed in the same user transaction.
As a first step in improving its performance and scalability
(issue cockroachdb#25828) we needed to split the responsibility of creating a new
TableDescriptor, and executing the AS query.

While the user txn continues to create and store the new desc, the
execution has been made async by moving the logic to the
SchemaChanger. This requires the SchemaChanger to be able to
bootstrap its state from the desc it reads, thereby requiring the
addition of these fields.

Release note: None
  • Loading branch information
adityamaru27 committed Jun 6, 2019
1 parent 3f2470f commit cba5539
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/sqlbase/structured.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,12 @@ func (desc *TableDescriptor) IsView() bool {
return desc.ViewQuery != ""
}

// IsAs returns true if the TableDescriptor actually describes
// a Table resource with an As source.
func (desc *TableDescriptor) IsAs() bool {
return desc.CreateQuery != ""
}

// IsSequence returns true if the TableDescriptor actually describes a
// Sequence resource rather than a Table.
func (desc *TableDescriptor) IsSequence() bool {
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/sqlbase/structured.proto
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@ message TableDescriptor {
// index case. Also use for dropped interleaved indexes and columns.
repeated GCDescriptorMutation gc_mutations = 33 [(gogoproto.nullable) = false,
(gogoproto.customname) = "GCMutations"];

optional string create_query = 34 [(gogoproto.nullable) = false];
optional util.hlc.Timestamp create_as_of_time = 35 [(gogoproto.nullable) = false];
}

// DatabaseDescriptor represents a namespace (aka database) and is stored
Expand Down

0 comments on commit cba5539

Please sign in to comment.