github.com/dolthub/go-mysql-server@v0.18.0/sql/plan/dual.go (about)

     1  // Copyright 2022 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package plan
    16  
    17  import (
    18  	"strings"
    19  
    20  	"github.com/dolthub/go-mysql-server/memory"
    21  	"github.com/dolthub/go-mysql-server/sql"
    22  )
    23  
    24  // DualTableName is empty string because no table with empty name can be created
    25  const DualTableName = ""
    26  
    27  // IsDualTable returns whether the given table is the "dual" table.
    28  func IsDualTable(t sql.Table) bool {
    29  	if t == nil {
    30  		return false
    31  	}
    32  	return strings.ToLower(t.Name()) == DualTableName && t.Schema().Equals(memory.DualTableSchema.Schema)
    33  }
    34  
    35  var dualTable = func() sql.Table {
    36  	return memory.NewDualTable()
    37  }()
    38  
    39  // NewDualSqlTable creates a new Dual table.
    40  func NewDualSqlTable() sql.Table {
    41  	return dualTable
    42  }