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

     1  // Copyright 2023 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 planbuilder
    16  
    17  import (
    18  	"regexp"
    19  
    20  	"gopkg.in/src-d/go-errors.v1"
    21  )
    22  
    23  var (
    24  	errInvalidDescribeFormat = errors.NewKind("invalid format %q for DESCRIBE, supported formats: %s")
    25  
    26  	errInvalidSortOrder = errors.NewKind("invalid sort order: %s")
    27  
    28  	ErrPrimaryKeyOnNullField = errors.NewKind("All parts of PRIMARY KEY must be NOT NULL")
    29  
    30  	// TODO: We parse table options in Vitess, but we return them to GMS as a single string, so GMS has to reparse
    31  	//       table options using these regexes. It would be cleaner for Vitess to parse them into structures so that
    32  	//       GMS could just pull out the data it needs, without having to regex it out from a single string. Because
    33  	//       of how the original quotes are lost and single quotes are always used, we also currently lose some info
    34  	//       about the original statement – notably, we can't parse comments that contain single quotes because Vitess
    35  	//       strips the original double quotes and sends the comment string to GMS wrapped in single quotes.
    36  	tableCharsetOptionRegex   = regexp.MustCompile(`(?i)(DEFAULT)?\s+CHARACTER\s+SET((\s*=?\s*)|\s+)([A-Za-z0-9_]+)`)
    37  	tableCollationOptionRegex = regexp.MustCompile(`(?i)(DEFAULT)?\s+COLLATE((\s*=?\s*)|\s+)([A-Za-z0-9_]+)`)
    38  	tableCommentOptionRegex   = regexp.MustCompile(`(?i)\s+COMMENT((\s*=?\s*)|\s+)('([^']+)')`)
    39  
    40  	// ErrUnionSchemasDifferentLength is returned when the two sides of a
    41  	// UNION do not have the same number of columns in their schemas.
    42  	ErrUnionSchemasDifferentLength = errors.NewKind(
    43  		"cannot union two queries whose schemas are different lengths; left has %d column(s) right has %d column(s).",
    44  	)
    45  
    46  	ErrQualifiedOrderBy = errors.NewKind("Table '%s' from one of the SELECTs cannot be used in global ORDER clause")
    47  
    48  	ErrOrderByBinding = errors.NewKind("bindings in sort clauses not supported yet")
    49  
    50  	ErrFailedToParseStats = errors.NewKind("failed to parse data: %s\n%s")
    51  )