github.com/matrixorigin/matrixone@v1.2.0/pkg/frontend/variables.go (about)

     1  // Copyright 2022 Matrix Origin
     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 frontend
    16  
    17  import (
    18  	"context"
    19  	"fmt"
    20  	"math"
    21  	bits2 "math/bits"
    22  	"strconv"
    23  	"strings"
    24  	"sync"
    25  	"time"
    26  
    27  	"github.com/matrixorigin/matrixone/pkg/common/moerr"
    28  	"github.com/matrixorigin/matrixone/pkg/container/types"
    29  	"github.com/matrixorigin/matrixone/pkg/defines"
    30  )
    31  
    32  var (
    33  	errorConvertToBoolFailed                   = moerr.NewInternalError(context.Background(), "convert to the system variable bool type failed")
    34  	errorConvertToIntFailed                    = moerr.NewInternalError(context.Background(), "convert to the system variable int type failed")
    35  	errorConvertToUintFailed                   = moerr.NewInternalError(context.Background(), "convert to the system variable uint type failed")
    36  	errorConvertToDoubleFailed                 = moerr.NewInternalError(context.Background(), "convert to the system variable double type failed")
    37  	errorConvertToEnumFailed                   = moerr.NewInternalError(context.Background(), "convert to the system variable enum type failed")
    38  	errorConvertToSetFailed                    = moerr.NewInternalError(context.Background(), "convert to the system variable set type failed")
    39  	errorConvertToStringFailed                 = moerr.NewInternalError(context.Background(), "convert to the system variable string type failed")
    40  	errorConvertToNullFailed                   = moerr.NewInternalError(context.Background(), "convert to the system variable null type failed")
    41  	errorConvertFromStringToBoolFailedFormat   = "convert from string %s to the system variable bool type failed"
    42  	errorConvertFromStringToIntFailedFormat    = "convert from string %s to the system variable int type failed"
    43  	errorConvertFromStringToUintFailedFormat   = "convert from string %s to the system variable uint type failed"
    44  	errorConvertFromStringToDoubleFailedFormat = "convert from string %s to the system variable double type failed"
    45  	errorConvertFromStringToEnumFailedFormat   = "convert from string %s to the system variable enum type failed"
    46  	errorConvertFromStringToSetFailedFormat    = "convert from string %s to the system variable set type failed"
    47  	errorConvertFromStringToNullFailedFormat   = "convert from string %s  to the system variable null type failed"
    48  )
    49  
    50  func getErrorConvertFromStringToBoolFailed(str string) error {
    51  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToBoolFailedFormat, str)
    52  }
    53  
    54  func getErrorConvertFromStringToIntFailed(str string) error {
    55  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToIntFailedFormat, str)
    56  }
    57  
    58  func getErrorConvertFromStringToUintFailed(str string) error {
    59  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToUintFailedFormat, str)
    60  }
    61  
    62  func getErrorConvertFromStringToDoubleFailed(str string) error {
    63  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToDoubleFailedFormat, str)
    64  }
    65  
    66  func getErrorConvertFromStringToEnumFailed(str string) error {
    67  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToEnumFailedFormat, str)
    68  }
    69  
    70  func getErrorConvertFromStringToSetFailed(str string) error {
    71  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToSetFailedFormat, str)
    72  }
    73  
    74  func getErrorConvertFromStringToNullFailed(str string) error {
    75  	return moerr.NewInternalError(context.Background(), errorConvertFromStringToNullFailedFormat, str)
    76  }
    77  
    78  func errorSystemVariableDoesNotExist() string { return "the system variable does not exist" }
    79  func errorSystemVariableIsSession() string    { return "the system variable is session" }
    80  func errorSystemVariableSessionEmpty() string {
    81  	return "the value of the system variable with scope session is empty"
    82  }
    83  func errorSystemVariableIsGlobal() string   { return "the system variable is global" }
    84  func errorSystemVariableIsReadOnly() string { return "the system variable is read only" }
    85  
    86  type Scope int
    87  
    88  const (
    89  	ScopeGlobal       Scope = iota //it is only in global
    90  	ScopeSession                   //it is only in session
    91  	ScopeBoth                      //it is both in global and session
    92  	ScopePersist                   //it is global and persisted
    93  	ScopePersistOnly               //it is persisted without updating global and session values
    94  	ScopeResetPersist              //to remove a persisted variable
    95  )
    96  
    97  func (s Scope) String() string {
    98  	switch s {
    99  	case ScopeGlobal:
   100  		return "GLOBAL"
   101  	case ScopeSession:
   102  		return "SESSION"
   103  	case ScopeBoth:
   104  		return "GLOBAL, SESSION"
   105  	case ScopePersist:
   106  		return "GLOBAL, PERSIST"
   107  	case ScopePersistOnly:
   108  		return "PERSIST"
   109  	case ScopeResetPersist:
   110  		return "RESET PERSIST"
   111  	default:
   112  		return "UNKNOWN_SYSTEM_SCOPE"
   113  	}
   114  }
   115  
   116  type SystemVariableType interface {
   117  	fmt.Stringer
   118  
   119  	// Convert the value to another value of the type
   120  	Convert(value interface{}) (interface{}, error)
   121  
   122  	// Type gets the type in the computation engine
   123  	Type() types.T
   124  
   125  	// MysqlType gets the mysql type
   126  	MysqlType() defines.MysqlType
   127  
   128  	// Zero gets the zero value for the type
   129  	Zero() interface{}
   130  
   131  	// Convert the value from string to another value of the type
   132  	ConvertFromString(value string) (interface{}, error)
   133  }
   134  
   135  var _ SystemVariableType = SystemVariableBoolType{}
   136  var _ SystemVariableType = SystemVariableIntType{}
   137  var _ SystemVariableType = SystemVariableUintType{}
   138  var _ SystemVariableType = SystemVariableDoubleType{}
   139  var _ SystemVariableType = SystemVariableEnumType{}
   140  var _ SystemVariableType = SystemVariableSetType{}
   141  var _ SystemVariableType = SystemVariableStringType{}
   142  var _ SystemVariableType = SystemVariableNullType{}
   143  
   144  type SystemVariableNullType struct {
   145  }
   146  
   147  func (svnt SystemVariableNullType) String() string {
   148  	return "NULL"
   149  }
   150  
   151  func (svnt SystemVariableNullType) Convert(value interface{}) (interface{}, error) {
   152  	if value != nil {
   153  		return nil, errorConvertToNullFailed
   154  	}
   155  	return nil, nil
   156  }
   157  
   158  func (svnt SystemVariableNullType) Type() types.T {
   159  	return types.T_any
   160  }
   161  
   162  func (svnt SystemVariableNullType) MysqlType() defines.MysqlType {
   163  	return defines.MYSQL_TYPE_NULL
   164  }
   165  
   166  func (svnt SystemVariableNullType) Zero() interface{} {
   167  	return nil
   168  }
   169  
   170  func (svnt SystemVariableNullType) ConvertFromString(value string) (interface{}, error) {
   171  	if len(value) != 0 {
   172  		return nil, getErrorConvertFromStringToNullFailed(value)
   173  	}
   174  	return nil, nil
   175  }
   176  
   177  type SystemVariableBoolType struct {
   178  	name string
   179  }
   180  
   181  func InitSystemVariableBoolType(name string) SystemVariableBoolType {
   182  	return SystemVariableBoolType{
   183  		name: name,
   184  	}
   185  }
   186  
   187  func (svbt SystemVariableBoolType) String() string {
   188  	return "BOOL"
   189  }
   190  
   191  func (svbt SystemVariableBoolType) Convert(value interface{}) (interface{}, error) {
   192  	cv1 := func(x int8) (interface{}, error) {
   193  		if x == 0 || x == 1 {
   194  			return x, nil
   195  		}
   196  		return nil, errorConvertToBoolFailed
   197  	}
   198  	cv2 := func(x float64) (interface{}, error) {
   199  		xx := int64(x)
   200  		rxx := float64(xx)
   201  		if x == rxx {
   202  			return cv1(int8(xx))
   203  		}
   204  		return nil, errorConvertToBoolFailed
   205  	}
   206  	cv3 := func(x string) (interface{}, error) {
   207  		switch strings.ToLower(x) {
   208  		case "on", "true", "1":
   209  			return int8(1), nil
   210  		case "off", "false", "0":
   211  			return int8(0), nil
   212  		}
   213  		return nil, errorConvertToBoolFailed
   214  	}
   215  	switch v := value.(type) {
   216  	case int:
   217  		return cv1(int8(v))
   218  	case uint:
   219  		return cv1(int8(v))
   220  	case int8:
   221  		return cv1(v)
   222  	case int16:
   223  		return cv1(int8(v))
   224  	case uint16:
   225  		return cv1(int8(v))
   226  	case int32:
   227  		return cv1(int8(v))
   228  	case uint32:
   229  		return cv1(int8(v))
   230  	case int64:
   231  		return cv1(int8(v))
   232  	case uint64:
   233  		return cv1(int8(v))
   234  	case bool:
   235  		if v {
   236  			return int8(1), nil
   237  		} else {
   238  			return int8(0), nil
   239  		}
   240  	case float32:
   241  		return cv2(float64(v))
   242  	case float64:
   243  		return cv2(v)
   244  	case string:
   245  		return cv3(v)
   246  	}
   247  	return nil, errorConvertToBoolFailed
   248  }
   249  
   250  func (svbt SystemVariableBoolType) IsTrue(v interface{}) bool {
   251  	switch vv := v.(type) {
   252  	case int:
   253  		return vv == 1
   254  	case uint:
   255  		return vv == uint(1)
   256  	case int8:
   257  		return vv == int8(1)
   258  	case uint8:
   259  		return vv == uint8(1)
   260  	case int16:
   261  		return vv == int16(1)
   262  	case uint16:
   263  		return vv == uint16(1)
   264  	case int32:
   265  		return vv == int32(1)
   266  	case uint32:
   267  		return vv == uint32(1)
   268  	case int64:
   269  		return vv == int64(1)
   270  	case uint64:
   271  		return vv == uint64(1)
   272  	case bool:
   273  		return vv
   274  	case string:
   275  		return strings.ToLower(vv) == "on"
   276  	default:
   277  		return false
   278  	}
   279  }
   280  
   281  func (svbt SystemVariableBoolType) Type() types.T {
   282  	return types.T_bool
   283  }
   284  
   285  func (svbt SystemVariableBoolType) MysqlType() defines.MysqlType {
   286  	return defines.MYSQL_TYPE_BOOL
   287  }
   288  
   289  func (svbt SystemVariableBoolType) Zero() interface{} {
   290  	return int8(0)
   291  }
   292  
   293  func (svbt SystemVariableBoolType) ConvertFromString(value string) (interface{}, error) {
   294  	if value == "on" {
   295  		return int8(1), nil
   296  	} else if value == "off" {
   297  		return int8(0), nil
   298  	}
   299  
   300  	convertVal, err := strconv.ParseInt(value, 10, 8)
   301  	if err != nil {
   302  		return nil, getErrorConvertFromStringToBoolFailed(value)
   303  	}
   304  	if convertVal != 1 && convertVal != 0 {
   305  		return nil, getErrorConvertFromStringToBoolFailed(value)
   306  	}
   307  	return int8(convertVal), nil
   308  
   309  }
   310  
   311  type SystemVariableIntType struct {
   312  	name    string
   313  	minimum int64
   314  	maximum int64
   315  	//-1 ?
   316  	maybeMinusOne bool
   317  }
   318  
   319  func InitSystemVariableIntType(name string, minimum, maximum int64, maybeMinusOne bool) SystemVariableIntType {
   320  	return SystemVariableIntType{
   321  		name:          name,
   322  		minimum:       minimum,
   323  		maximum:       maximum,
   324  		maybeMinusOne: maybeMinusOne,
   325  	}
   326  }
   327  
   328  func (svit SystemVariableIntType) String() string {
   329  	return "INT"
   330  }
   331  
   332  func (svit SystemVariableIntType) Convert(value interface{}) (interface{}, error) {
   333  	cv1 := func(x int64) (interface{}, error) {
   334  		if x >= svit.minimum && x <= svit.maximum {
   335  			return x, nil
   336  		} else if svit.maybeMinusOne && x == -1 {
   337  			return x, nil
   338  		}
   339  		return nil, errorConvertToIntFailed
   340  	}
   341  	cv2 := func(x float64) (interface{}, error) {
   342  		xx := int64(x)
   343  		rxx := float64(xx)
   344  		if x == rxx {
   345  			return cv1(xx)
   346  		}
   347  		return nil, errorConvertToIntFailed
   348  	}
   349  
   350  	cv3 := func(x string) (interface{}, error) {
   351  		convertVal, err := strconv.ParseInt(x, 10, 64)
   352  		if err != nil {
   353  			return nil, errorConvertToIntFailed
   354  		}
   355  		return cv1(convertVal)
   356  	}
   357  
   358  	switch v := value.(type) {
   359  	case int:
   360  		return cv1(int64(v))
   361  	case uint:
   362  		return cv1(int64(v))
   363  	case int8:
   364  		return cv1(int64(v))
   365  	case uint8:
   366  		return cv1(int64(v))
   367  	case int16:
   368  		return cv1(int64(v))
   369  	case uint16:
   370  		return cv1(int64(v))
   371  	case int32:
   372  		return cv1(int64(v))
   373  	case uint32:
   374  		return cv1(int64(v))
   375  	case int64:
   376  		return cv1(v)
   377  	case uint64:
   378  		return cv1(int64(v))
   379  	case float32:
   380  		return cv2(float64(v))
   381  	case float64:
   382  		return cv2(v)
   383  	case string:
   384  		return cv3(v)
   385  	}
   386  	return nil, errorConvertToIntFailed
   387  }
   388  
   389  func (svit SystemVariableIntType) Type() types.T {
   390  	return types.T_int64
   391  }
   392  
   393  func (svit SystemVariableIntType) MysqlType() defines.MysqlType {
   394  	return defines.MYSQL_TYPE_LONGLONG
   395  }
   396  
   397  func (svit SystemVariableIntType) Zero() interface{} {
   398  	return int64(0)
   399  }
   400  
   401  func (svit SystemVariableIntType) ConvertFromString(value string) (interface{}, error) {
   402  	convertVal, err := strconv.ParseInt(value, 10, 64)
   403  	if err != nil {
   404  		return nil, getErrorConvertFromStringToIntFailed(value)
   405  	}
   406  	return convertVal, nil
   407  }
   408  
   409  type SystemVariableUintType struct {
   410  	name    string
   411  	minimum uint64
   412  	maximum uint64
   413  }
   414  
   415  func InitSystemVariableUintType(name string, minimum, maximum uint64) SystemVariableUintType {
   416  	return SystemVariableUintType{
   417  		name:    name,
   418  		minimum: minimum,
   419  		maximum: maximum,
   420  	}
   421  }
   422  
   423  func (svut SystemVariableUintType) String() string {
   424  	return "UINT"
   425  }
   426  
   427  func (svut SystemVariableUintType) Convert(value interface{}) (interface{}, error) {
   428  	cv1 := func(x uint64) (interface{}, error) {
   429  		if x >= svut.minimum && x <= svut.maximum {
   430  			return x, nil
   431  		}
   432  		return nil, errorConvertToUintFailed
   433  	}
   434  	cv2 := func(x float64) (interface{}, error) {
   435  		xx := uint64(x)
   436  		rxx := float64(xx)
   437  		if x == rxx {
   438  			return cv1(xx)
   439  		}
   440  		return nil, errorConvertToUintFailed
   441  	}
   442  
   443  	switch v := value.(type) {
   444  	case int:
   445  		return cv1(uint64(v))
   446  	case uint:
   447  		return cv1(uint64(v))
   448  	case int8:
   449  		return cv1(uint64(v))
   450  	case uint8:
   451  		return cv1(uint64(v))
   452  	case int16:
   453  		return cv1(uint64(v))
   454  	case uint16:
   455  		return cv1(uint64(v))
   456  	case int32:
   457  		return cv1(uint64(v))
   458  	case uint32:
   459  		return cv1(uint64(v))
   460  	case int64:
   461  		return cv1(uint64(v))
   462  	case uint64:
   463  		return cv1(v)
   464  	case float32:
   465  		return cv2(float64(v))
   466  	case float64:
   467  		return cv2(v)
   468  	}
   469  	return nil, errorConvertToUintFailed
   470  }
   471  
   472  func (svut SystemVariableUintType) Type() types.T {
   473  	return types.T_uint64
   474  }
   475  
   476  func (svut SystemVariableUintType) MysqlType() defines.MysqlType {
   477  	return defines.MYSQL_TYPE_LONGLONG
   478  }
   479  
   480  func (svut SystemVariableUintType) Zero() interface{} {
   481  	return uint64(0)
   482  }
   483  
   484  func (svut SystemVariableUintType) ConvertFromString(value string) (interface{}, error) {
   485  	convertVal, err := strconv.ParseUint(value, 10, 64)
   486  	if err != nil {
   487  		return nil, getErrorConvertFromStringToUintFailed(value)
   488  	}
   489  	return convertVal, nil
   490  }
   491  
   492  type SystemVariableDoubleType struct {
   493  	name    string
   494  	minimum float64
   495  	maximum float64
   496  }
   497  
   498  func InitSystemVariableDoubleType(name string, minimum, maximum float64) SystemVariableDoubleType {
   499  	return SystemVariableDoubleType{
   500  		name:    name,
   501  		minimum: minimum,
   502  		maximum: maximum,
   503  	}
   504  }
   505  
   506  func (svdt SystemVariableDoubleType) String() string {
   507  	return "DOUBLE"
   508  }
   509  
   510  func (svdt SystemVariableDoubleType) Convert(value interface{}) (interface{}, error) {
   511  	cv1 := func(x float64) (interface{}, error) {
   512  		if x >= svdt.minimum && x <= svdt.maximum {
   513  			return x, nil
   514  		}
   515  		return nil, errorConvertToUintFailed
   516  	}
   517  
   518  	switch v := value.(type) {
   519  	case int:
   520  		return cv1(float64(v))
   521  	case uint:
   522  		return cv1(float64(v))
   523  	case int8:
   524  		return cv1(float64(v))
   525  	case uint8:
   526  		return cv1(float64(v))
   527  	case int16:
   528  		return cv1(float64(v))
   529  	case uint16:
   530  		return cv1(float64(v))
   531  	case int32:
   532  		return cv1(float64(v))
   533  	case uint32:
   534  		return cv1(float64(v))
   535  	case int64:
   536  		return cv1(float64(v))
   537  	case uint64:
   538  		return cv1(float64(v))
   539  	case float32:
   540  		return cv1(float64(v))
   541  	case float64:
   542  		return cv1(v)
   543  	case string:
   544  		// some case '0.1' is recognized as string
   545  		if f, err := strconv.ParseFloat(v, 64); err == nil {
   546  			return cv1(f)
   547  		}
   548  	}
   549  	return nil, errorConvertToDoubleFailed
   550  }
   551  
   552  func (svdt SystemVariableDoubleType) Type() types.T {
   553  	return types.T_float64
   554  }
   555  
   556  func (svdt SystemVariableDoubleType) MysqlType() defines.MysqlType {
   557  	return defines.MYSQL_TYPE_DOUBLE
   558  }
   559  
   560  func (svdt SystemVariableDoubleType) Zero() interface{} {
   561  	return float64(0)
   562  }
   563  
   564  func (svdt SystemVariableDoubleType) ConvertFromString(value string) (interface{}, error) {
   565  	convertVal, err := strconv.ParseFloat(value, 64)
   566  	if err != nil {
   567  		return nil, getErrorConvertFromStringToDoubleFailed(value)
   568  	}
   569  	return convertVal, nil
   570  }
   571  
   572  var (
   573  	// panic
   574  	errorEnumHasMoreThan65535Values = moerr.NewInternalError(context.Background(), "the enum has more than 65535 values")
   575  )
   576  
   577  type SystemVariableEnumType struct {
   578  	name string
   579  	//tag name -> id
   580  	tagName2Id map[string]int
   581  
   582  	// id -> tag name
   583  	id2TagName []string
   584  }
   585  
   586  func InitSystemSystemEnumType(name string, values ...string) SystemVariableEnumType {
   587  	if len(values) > 65535 {
   588  		panic(errorEnumHasMoreThan65535Values)
   589  	}
   590  	tagName2Id := make(map[string]int)
   591  	for i, value := range values {
   592  		tagName2Id[strings.ToLower(value)] = i
   593  	}
   594  	return SystemVariableEnumType{
   595  		name:       name,
   596  		tagName2Id: tagName2Id,
   597  		id2TagName: values,
   598  	}
   599  }
   600  
   601  func (svet SystemVariableEnumType) String() string {
   602  	return "ENUM"
   603  }
   604  
   605  func (svet SystemVariableEnumType) Convert(value interface{}) (interface{}, error) {
   606  	cv1 := func(x int) (interface{}, error) {
   607  		if x >= 0 && x <= len(svet.id2TagName) {
   608  			return svet.id2TagName[x], nil
   609  		}
   610  		return nil, errorConvertToEnumFailed
   611  	}
   612  	cv2 := func(x float64) (interface{}, error) {
   613  		xx := int(x)
   614  		rxx := float64(xx)
   615  		if x == rxx {
   616  			return cv1(xx)
   617  		}
   618  		return nil, errorConvertToUintFailed
   619  	}
   620  
   621  	switch v := value.(type) {
   622  	case int:
   623  		return cv1(v)
   624  	case uint:
   625  		return cv1(int(v))
   626  	case int8:
   627  		return cv1(int(v))
   628  	case uint8:
   629  		return cv1(int(v))
   630  	case int16:
   631  		return cv1(int(v))
   632  	case uint16:
   633  		return cv1(int(v))
   634  	case int32:
   635  		return cv1(int(v))
   636  	case uint32:
   637  		return cv1(int(v))
   638  	case int64:
   639  		return cv1(int(v))
   640  	case uint64:
   641  		return cv1(int(v))
   642  	case float32:
   643  		return cv2(float64(v))
   644  	case float64:
   645  		return cv2(v)
   646  	case string:
   647  		if id, ok := svet.tagName2Id[strings.ToLower(v)]; ok {
   648  			return svet.id2TagName[id], nil
   649  		}
   650  	}
   651  	return nil, errorConvertToEnumFailed
   652  }
   653  
   654  func (svet SystemVariableEnumType) Type() types.T {
   655  	return types.T_varchar
   656  }
   657  
   658  func (svet SystemVariableEnumType) MysqlType() defines.MysqlType {
   659  	return defines.MYSQL_TYPE_VARCHAR
   660  }
   661  
   662  func (svet SystemVariableEnumType) Zero() interface{} {
   663  	return ""
   664  }
   665  
   666  func (svet SystemVariableEnumType) ConvertFromString(value string) (interface{}, error) {
   667  	lowerName := strings.ToLower(value)
   668  	if val, ok := svet.tagName2Id[lowerName]; !ok {
   669  		return nil, getErrorConvertFromStringToEnumFailed(value)
   670  	} else {
   671  		return val, nil
   672  	}
   673  }
   674  
   675  const (
   676  	//reference : https://dev.mysql.com/doc/refman/8.0/en/storage-requirements.html#data-types-storage-reqs-strings
   677  	MaxMemberCountOfSetType = 64
   678  )
   679  
   680  var (
   681  	// panic error
   682  	errorValuesOfSetIsEmpty       = moerr.NewInternalError(context.Background(), "the count of values for set is empty")
   683  	errorValuesOfSetGreaterThan64 = moerr.NewInternalError(context.Background(), "the count of value is greater than 64")
   684  	errorValueHasComma            = moerr.NewInternalError(context.Background(), "the value has the comma")
   685  	errorValueIsDuplicate         = moerr.NewInternalError(context.Background(), "the value is duplicate")
   686  	errorValuesAreNotEnough       = moerr.NewInternalError(context.Background(), "values are not enough") // convert
   687  	errorValueIsInvalid           = moerr.NewInternalError(context.Background(), "the value is invalid")  // convert
   688  )
   689  
   690  type SystemVariableSetType struct {
   691  	// name                string
   692  	normalized2original map[string]string
   693  	value2BitIndex      map[string]int
   694  	bitIndex2Value      map[int]string
   695  }
   696  
   697  func (svst SystemVariableSetType) String() string {
   698  	return fmt.Sprintf("SET('%v')",
   699  		strings.Join(svst.Values(), "','"))
   700  }
   701  
   702  func (svst SystemVariableSetType) Values() []string {
   703  	bitsCount := 64 - bits2.LeadingZeros64(svst.bitmap())
   704  	var res []string
   705  	for i := 0; i < bitsCount; i++ {
   706  		res = append(res, svst.bitIndex2Value[i])
   707  	}
   708  	return res
   709  }
   710  
   711  func (svst SystemVariableSetType) bitmap() uint64 {
   712  	cnt := uint64(len(svst.value2BitIndex))
   713  	if cnt == 64 {
   714  		return math.MaxUint64
   715  	}
   716  	return uint64(1<<cnt) - 1
   717  }
   718  
   719  func (svst SystemVariableSetType) bits2string(bits uint64) (string, error) {
   720  	bld := strings.Builder{}
   721  	bitCount := 64 - bits2.LeadingZeros64(bits)
   722  	if bitCount > len(svst.bitIndex2Value) {
   723  		return "", errorValuesAreNotEnough
   724  	}
   725  
   726  	for i := 0; i < bitCount; i++ {
   727  		mask := uint64(1 << uint64(i))
   728  		if mask&bits != 0 {
   729  			v, ok := svst.bitIndex2Value[i]
   730  			if !ok {
   731  				return "", errorValueIsInvalid
   732  			}
   733  			bld.WriteString(v)
   734  			if i != 0 {
   735  				bld.WriteByte(',')
   736  			}
   737  		}
   738  	}
   739  
   740  	bldString := bld.String()
   741  	if len(bldString) == 0 {
   742  		return bldString, nil
   743  	}
   744  	return bldString[:len(bldString)-1], nil
   745  }
   746  
   747  func (svst SystemVariableSetType) string2bits(s string) (uint64, error) {
   748  	if len(s) == 0 {
   749  		return 0, nil
   750  	}
   751  	ss := strings.Split(s, ",")
   752  	bits := uint64(0)
   753  	for _, sss := range ss {
   754  		normalized := strings.ToLower(strings.TrimRight(sss, " "))
   755  		if origin, ok := svst.normalized2original[normalized]; ok {
   756  			bits |= 1 << svst.value2BitIndex[origin]
   757  		} else {
   758  			if x, err := strconv.ParseUint(sss, 10, 64); err == nil {
   759  				if x == 0 {
   760  					continue
   761  				}
   762  				bitsCount := bits2.TrailingZeros64(x)
   763  				xv := 1 << uint64(bitsCount)
   764  				if _, ok2 := svst.bitIndex2Value[xv]; ok2 {
   765  					bits |= uint64(xv)
   766  					continue
   767  				}
   768  			}
   769  			return 0, errorValueIsInvalid
   770  		}
   771  	}
   772  	return bits, nil
   773  }
   774  
   775  func (svst SystemVariableSetType) Convert(value interface{}) (interface{}, error) {
   776  	if value == nil {
   777  		return nil, nil
   778  	}
   779  	cv1 := func(x uint64) (interface{}, error) {
   780  		if x <= svst.bitmap() {
   781  			return svst.bits2string(x)
   782  		}
   783  		return nil, errorConvertToSetFailed
   784  	}
   785  	cv2 := func(x string) (interface{}, error) {
   786  		bits, err := svst.string2bits(x)
   787  		if err != nil {
   788  			return nil, err
   789  		}
   790  		return svst.bits2string(bits)
   791  	}
   792  
   793  	switch v := value.(type) {
   794  	case int:
   795  		return cv1(uint64(v))
   796  	case uint:
   797  		return cv1(uint64(v))
   798  	case int8:
   799  		return cv1(uint64(v))
   800  	case uint8:
   801  		return cv1(uint64(v))
   802  	case int16:
   803  		return cv1(uint64(v))
   804  	case uint16:
   805  		return cv1(uint64(v))
   806  	case int32:
   807  		return cv1(uint64(v))
   808  	case uint32:
   809  		return cv1(uint64(v))
   810  	case int64:
   811  		return cv1(uint64(v))
   812  	case uint64:
   813  		return cv1(v)
   814  	case float32:
   815  		return cv1(uint64(v))
   816  	case float64:
   817  		return cv1(uint64(v))
   818  	case string:
   819  		return cv2(v)
   820  	case []byte:
   821  		return cv2(string(v))
   822  	}
   823  	return nil, errorConvertToSetFailed
   824  }
   825  
   826  func (svst SystemVariableSetType) Type() types.T {
   827  	return types.T_any
   828  }
   829  
   830  func (svst SystemVariableSetType) MysqlType() defines.MysqlType {
   831  	return defines.MYSQL_TYPE_SET
   832  }
   833  
   834  func (svst SystemVariableSetType) Zero() interface{} {
   835  	return ""
   836  }
   837  
   838  func (svst SystemVariableSetType) ConvertFromString(value string) (interface{}, error) {
   839  	bits, err := svst.string2bits(value)
   840  	if err != nil {
   841  		return nil, getErrorConvertFromStringToSetFailed(value)
   842  	}
   843  	return svst.bits2string(bits)
   844  }
   845  
   846  func InitSystemVariableSetType(name string, values ...string) SystemVariableSetType {
   847  	if len(values) == 0 {
   848  		panic(errorValuesOfSetIsEmpty)
   849  	}
   850  	if len(values) > MaxMemberCountOfSetType {
   851  		panic(errorValuesOfSetGreaterThan64)
   852  	}
   853  
   854  	normalized2original := make(map[string]string)
   855  	value2BitIndex := make(map[string]int)
   856  	bitIndex2Value := make(map[int]string)
   857  	for i, value := range values {
   858  		if strings.Contains(value, ",") {
   859  			panic(errorValueHasComma)
   860  		}
   861  		v := strings.TrimRight(value, " ")
   862  		lv := strings.ToLower(v)
   863  		if _, ok := normalized2original[lv]; ok {
   864  			panic(errorValueIsDuplicate)
   865  		}
   866  		normalized2original[lv] = v
   867  		value2BitIndex[v] = i
   868  		bitIndex2Value[i] = v
   869  	}
   870  
   871  	return SystemVariableSetType{
   872  		normalized2original: normalized2original,
   873  		value2BitIndex:      value2BitIndex,
   874  		bitIndex2Value:      bitIndex2Value,
   875  	}
   876  }
   877  
   878  type SystemVariableStringType struct {
   879  	name string
   880  }
   881  
   882  func InitSystemVariableStringType(name string) SystemVariableStringType {
   883  	return SystemVariableStringType{
   884  		name: name,
   885  	}
   886  }
   887  
   888  func (svst SystemVariableStringType) String() string {
   889  	return "STRING"
   890  }
   891  
   892  func (svst SystemVariableStringType) Convert(value interface{}) (interface{}, error) {
   893  	if value == nil {
   894  		return "", nil
   895  	}
   896  	if v, ok := value.(string); ok {
   897  		return v, nil
   898  	}
   899  	return nil, errorConvertToStringFailed
   900  }
   901  
   902  func (svst SystemVariableStringType) Type() types.T {
   903  	return types.T_varchar
   904  }
   905  
   906  func (svst SystemVariableStringType) MysqlType() defines.MysqlType {
   907  	return defines.MYSQL_TYPE_VARCHAR
   908  }
   909  
   910  func (svst SystemVariableStringType) Zero() interface{} {
   911  	return ""
   912  }
   913  
   914  func (svst SystemVariableStringType) ConvertFromString(value string) (interface{}, error) {
   915  	return value, nil
   916  }
   917  
   918  type SystemVariable struct {
   919  	Name string
   920  
   921  	// scope of the system variable includes Global,Session,Both
   922  	Scope Scope
   923  
   924  	// can be changed during runtime
   925  	Dynamic bool
   926  
   927  	//can be set for single query by SET_VAR()
   928  	SetVarHintApplies bool
   929  
   930  	Type SystemVariableType
   931  
   932  	Default interface{}
   933  
   934  	UpdateSessVar func(context.Context, *Session, map[string]interface{}, string, interface{}) error
   935  }
   936  
   937  func (sv SystemVariable) GetName() string {
   938  	return sv.Name
   939  }
   940  
   941  func (sv SystemVariable) GetScope() Scope {
   942  	return sv.Scope
   943  }
   944  
   945  func (sv SystemVariable) GetDynamic() bool {
   946  	return sv.Dynamic
   947  }
   948  
   949  func (sv SystemVariable) GetSetVarHintApplies() bool {
   950  	return sv.SetVarHintApplies
   951  }
   952  
   953  func (sv SystemVariable) GetType() SystemVariableType {
   954  	return sv.Type
   955  }
   956  
   957  func (sv SystemVariable) GetDefault() interface{} {
   958  	return sv.Default
   959  }
   960  
   961  type GlobalSystemVariables struct {
   962  	mu sync.Mutex
   963  	// name -> value/default
   964  	sysVars map[string]interface{}
   965  }
   966  
   967  // the set of variables
   968  var GSysVariables = &GlobalSystemVariables{
   969  	sysVars: make(map[string]interface{}),
   970  }
   971  
   972  // initialize system variables from definition
   973  func InitGlobalSystemVariables(gsv *GlobalSystemVariables) {
   974  	if gsv.sysVars == nil {
   975  		gsv.sysVars = make(map[string]interface{})
   976  	}
   977  	for _, def := range gSysVarsDefs {
   978  		gsv.sysVars[def.GetName()] = def.GetDefault()
   979  	}
   980  }
   981  
   982  // add custom system variables
   983  func (gsv *GlobalSystemVariables) AddSysVariables(vars []SystemVariable) {
   984  	gsv.mu.Lock()
   985  	defer gsv.mu.Unlock()
   986  	for _, v := range vars {
   987  		vv := v
   988  		lname := strings.ToLower(vv.GetName())
   989  		vv.Name = lname
   990  		gSysVarsDefs[lname] = vv
   991  		gsv.sysVars[lname] = vv.GetDefault()
   992  	}
   993  }
   994  
   995  // set values to system variables
   996  func (gsv *GlobalSystemVariables) SetValues(ctx context.Context, values map[string]interface{}) error {
   997  	gsv.mu.Lock()
   998  	defer gsv.mu.Unlock()
   999  	for name, val := range values {
  1000  		name = strings.ToLower(name)
  1001  		if sv, ok := gSysVarsDefs[name]; ok {
  1002  			cv, err := sv.GetType().Convert(val)
  1003  			if err != nil {
  1004  				return err
  1005  			}
  1006  			gsv.sysVars[name] = cv
  1007  		} else {
  1008  			return moerr.NewInternalError(ctx, errorSystemVariableDoesNotExist())
  1009  		}
  1010  	}
  1011  	return nil
  1012  }
  1013  
  1014  // copy global system variable to session
  1015  func (gsv *GlobalSystemVariables) CopySysVarsToSession() map[string]interface{} {
  1016  	gsv.mu.Lock()
  1017  	defer gsv.mu.Unlock()
  1018  	sesSysVars := make(map[string]interface{}, len(gsv.sysVars))
  1019  	for name, value := range gsv.sysVars {
  1020  		sesSysVars[name] = value
  1021  	}
  1022  	return sesSysVars
  1023  }
  1024  
  1025  // get system variable definition ,value.
  1026  // return false, if there is no such variable.
  1027  func (gsv *GlobalSystemVariables) GetGlobalSysVar(name string) (SystemVariable, interface{}, bool) {
  1028  	gsv.mu.Lock()
  1029  	defer gsv.mu.Unlock()
  1030  	name = strings.ToLower(name)
  1031  	if v, ok := gSysVarsDefs[name]; ok {
  1032  		return v, gsv.sysVars[name], true
  1033  	}
  1034  	return SystemVariable{}, nil, false
  1035  }
  1036  
  1037  // get the definition of the system variable
  1038  func (gsv *GlobalSystemVariables) GetDefinitionOfSysVar(name string) (SystemVariable, bool) {
  1039  	gsv.mu.Lock()
  1040  	defer gsv.mu.Unlock()
  1041  	name = strings.ToLower(name)
  1042  	if v, ok := gSysVarsDefs[name]; ok {
  1043  		return v, ok
  1044  	}
  1045  	return SystemVariable{}, false
  1046  }
  1047  
  1048  // set global dynamic variable by SET GLOBAL
  1049  func (gsv *GlobalSystemVariables) SetGlobalSysVar(ctx context.Context, name string, value interface{}) error {
  1050  	gsv.mu.Lock()
  1051  	defer gsv.mu.Unlock()
  1052  	name = strings.ToLower(name)
  1053  	if sv, ok := gSysVarsDefs[name]; ok {
  1054  		if sv.GetScope() == ScopeSession {
  1055  			return moerr.NewInternalError(ctx, errorSystemVariableIsSession())
  1056  		}
  1057  		if !sv.GetDynamic() {
  1058  			return moerr.NewInternalError(ctx, errorSystemVariableIsReadOnly())
  1059  		}
  1060  		val, err := sv.GetType().Convert(value)
  1061  		if err != nil {
  1062  			return err
  1063  		}
  1064  		gsv.sysVars[name] = val
  1065  	} else {
  1066  		return moerr.NewInternalError(ctx, errorSystemVariableDoesNotExist())
  1067  	}
  1068  	return nil
  1069  }
  1070  
  1071  func init() {
  1072  	InitGlobalSystemVariables(GSysVariables)
  1073  }
  1074  
  1075  // definitions of system variables
  1076  var gSysVarsDefs = map[string]SystemVariable{
  1077  	"port": {
  1078  		Name:              "port",
  1079  		Scope:             ScopeGlobal,
  1080  		Dynamic:           false,
  1081  		SetVarHintApplies: false,
  1082  		Type:              InitSystemVariableIntType("port", 0, 65535, false),
  1083  		Default:           int64(6001),
  1084  	},
  1085  	"host": {
  1086  		Name:              "host",
  1087  		Scope:             ScopeGlobal,
  1088  		Dynamic:           false,
  1089  		SetVarHintApplies: false,
  1090  		Type:              InitSystemVariableStringType("host"),
  1091  		Default:           "0.0.0.0",
  1092  	},
  1093  	"max_allowed_packet": {
  1094  		Name:              "max_allowed_packet",
  1095  		Scope:             ScopeBoth,
  1096  		Dynamic:           true,
  1097  		SetVarHintApplies: false,
  1098  		Type:              InitSystemVariableIntType("max_allowed_packet", 1024, 1073741824, false),
  1099  		Default:           int64(67108864),
  1100  	},
  1101  	"version_comment": {
  1102  		Name:              "version_comment",
  1103  		Scope:             ScopeGlobal,
  1104  		Dynamic:           false,
  1105  		SetVarHintApplies: false,
  1106  		Type:              InitSystemVariableStringType("version_comment"),
  1107  		Default:           "MatrixOne",
  1108  	},
  1109  	"tx_isolation": {
  1110  		Name:              "tx_isolation",
  1111  		Scope:             ScopeBoth,
  1112  		Dynamic:           true,
  1113  		SetVarHintApplies: false,
  1114  		Type:              InitSystemSystemEnumType("tx_isolation", "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE"),
  1115  		Default:           "REPEATABLE-READ",
  1116  	},
  1117  	"testglobalvar_dyn": {
  1118  		Name:              "testglobalvar_dyn",
  1119  		Scope:             ScopeGlobal,
  1120  		Dynamic:           true,
  1121  		SetVarHintApplies: false,
  1122  		Type:              InitSystemVariableIntType("testglobalvar_dyn", 0, 100, false),
  1123  		Default:           int64(0),
  1124  	},
  1125  	"testglobalvar_nodyn": {
  1126  		Name:              "testglobalvar_nodyn",
  1127  		Scope:             ScopeGlobal,
  1128  		Dynamic:           false,
  1129  		SetVarHintApplies: false,
  1130  		Type:              InitSystemVariableIntType("testglobalvar_nodyn", 0, 100, false),
  1131  		Default:           int64(0),
  1132  	},
  1133  	"testsessionvar_dyn": {
  1134  		Name:              "testsessionvar_dyn",
  1135  		Scope:             ScopeSession,
  1136  		Dynamic:           true,
  1137  		SetVarHintApplies: false,
  1138  		Type:              InitSystemVariableIntType("testsessionvar_dyn", 0, 100, false),
  1139  		Default:           int64(0),
  1140  	},
  1141  	"testsessionvar_nodyn": {
  1142  		Name:              "testsessionvar_nodyn",
  1143  		Scope:             ScopeSession,
  1144  		Dynamic:           false,
  1145  		SetVarHintApplies: false,
  1146  		Type:              InitSystemVariableIntType("testsessionvar_nodyn", 0, 100, false),
  1147  		Default:           int64(0),
  1148  	},
  1149  	"testbothvar_dyn": {
  1150  		Name:              "testbothvar_dyn",
  1151  		Scope:             ScopeBoth,
  1152  		Dynamic:           true,
  1153  		SetVarHintApplies: false,
  1154  		Type:              InitSystemVariableIntType("testbothvar_dyn", 0, 100, false),
  1155  		Default:           int64(0),
  1156  	},
  1157  	"testbotchvar_nodyn": {
  1158  		Name:              "testbotchvar_nodyn",
  1159  		Scope:             ScopeBoth,
  1160  		Dynamic:           false,
  1161  		SetVarHintApplies: false,
  1162  		Type:              InitSystemVariableIntType("testbotchvar_nodyn", 0, 100, false),
  1163  		Default:           int64(0),
  1164  	},
  1165  	"character_set_client": {
  1166  		Name:              "character_set_client",
  1167  		Scope:             ScopeBoth,
  1168  		Dynamic:           true,
  1169  		SetVarHintApplies: false,
  1170  		Type:              InitSystemVariableStringType("character_set_client"),
  1171  		Default:           "utf8mb4",
  1172  	},
  1173  	"character_set_server": {
  1174  		Name:              "character_set_server",
  1175  		Scope:             ScopeBoth,
  1176  		Dynamic:           true,
  1177  		SetVarHintApplies: false,
  1178  		Type:              InitSystemVariableStringType("character_set_server"),
  1179  		Default:           "utf8mb4",
  1180  	},
  1181  	"character_set_database": {
  1182  		Name:              "character_set_database",
  1183  		Scope:             ScopeBoth,
  1184  		Dynamic:           true,
  1185  		SetVarHintApplies: false,
  1186  		Type:              InitSystemVariableStringType("character_set_database"),
  1187  		Default:           "utf8mb4",
  1188  	},
  1189  	"character_set_connection": {
  1190  		Name:              "character_set_connection",
  1191  		Scope:             ScopeBoth,
  1192  		Dynamic:           true,
  1193  		SetVarHintApplies: false,
  1194  		Type:              InitSystemVariableStringType("character_set_connection"),
  1195  		Default:           "utf8mb4",
  1196  	},
  1197  	"character_set_results": {
  1198  		Name:              "character_set_results",
  1199  		Scope:             ScopeBoth,
  1200  		Dynamic:           true,
  1201  		SetVarHintApplies: false,
  1202  		Type:              InitSystemVariableStringType("character_set_results"),
  1203  		Default:           "utf8mb4",
  1204  	},
  1205  	"collation_connection": {
  1206  		Name:              "collation_connection",
  1207  		Scope:             ScopeBoth,
  1208  		Dynamic:           true,
  1209  		SetVarHintApplies: false,
  1210  		Type:              InitSystemVariableStringType("collation_connection"),
  1211  		Default:           "default",
  1212  	},
  1213  	"collation_server": {
  1214  		Name:              "collation_server",
  1215  		Scope:             ScopeGlobal,
  1216  		Dynamic:           true,
  1217  		SetVarHintApplies: false,
  1218  		Type:              InitSystemVariableStringType("collation_server"),
  1219  		Default:           "utf8mb4_bin",
  1220  	},
  1221  	"license": {
  1222  		Name:              "license",
  1223  		Scope:             ScopeGlobal,
  1224  		Dynamic:           true,
  1225  		SetVarHintApplies: false,
  1226  		Type:              InitSystemVariableStringType("license"),
  1227  		Default:           "APACHE",
  1228  	},
  1229  	"autocommit": {
  1230  		Name:              "autocommit",
  1231  		Scope:             ScopeBoth,
  1232  		Dynamic:           true,
  1233  		SetVarHintApplies: false,
  1234  		Type:              InitSystemVariableBoolType("autocommit"),
  1235  		Default:           int64(1),
  1236  	},
  1237  	"sql_mode": {
  1238  		Name:              "sql_mode",
  1239  		Scope:             ScopeBoth,
  1240  		Dynamic:           true,
  1241  		SetVarHintApplies: true,
  1242  		Type:              InitSystemVariableSetType("sql_mode", "ANSI", "TRADITIONAL", "ALLOW_INVALID_DATES", "ANSI_QUOTES", "ERROR_FOR_DIVISION_BY_ZERO", "HIGH_NOT_PRECEDENCE", "IGNORE_SPACE", "NO_AUTO_VALUE_ON_ZERO", "NO_BACKSLASH_ESCAPES", "NO_DIR_IN_CREATE", "NO_ENGINE_SUBSTITUTION", "NO_UNSIGNED_SUBTRACTION", "NO_ZERO_DATE", "NO_ZERO_IN_DATE", "ONLY_FULL_GROUP_BY", "PAD_CHAR_TO_FULL_LENGTH", "PIPES_AS_CONCAT", "REAL_AS_FLOAT", "STRICT_ALL_TABLES", "STRICT_TRANS_TABLES", "TIME_TRUNCATE_FRACTIONAL"),
  1243  		Default:           "ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES",
  1244  	},
  1245  	"completion_type": {
  1246  		Name:              "completion_type",
  1247  		Scope:             ScopeBoth,
  1248  		Dynamic:           true,
  1249  		SetVarHintApplies: false,
  1250  		Type:              InitSystemSystemEnumType("completion_type", "NO_CHAIN", "CHAIN", "RELEASE"),
  1251  		Default:           "NO_CHAIN",
  1252  	},
  1253  	"time_zone": {
  1254  		Name:              "time_zone",
  1255  		Scope:             ScopeBoth,
  1256  		Dynamic:           true,
  1257  		SetVarHintApplies: true,
  1258  		Type:              InitSystemVariableStringType("time_zone"),
  1259  		Default:           "SYSTEM",
  1260  		UpdateSessVar:     updateTimeZone,
  1261  	},
  1262  	"auto_increment_increment": {
  1263  		Name:              "auto_increment_increment",
  1264  		Scope:             ScopeBoth,
  1265  		Dynamic:           true,
  1266  		SetVarHintApplies: true,
  1267  		Type:              InitSystemVariableIntType("auto_increment_increment", 1, 65535, false),
  1268  		Default:           int64(1),
  1269  	},
  1270  	"auto_increment_offset": {
  1271  		Name:              "auto_increment_offset",
  1272  		Scope:             ScopeBoth,
  1273  		Dynamic:           true,
  1274  		SetVarHintApplies: true,
  1275  		Type:              InitSystemVariableIntType("auto_increment_offset", 1, 65535, false),
  1276  		Default:           int64(1),
  1277  	},
  1278  	"init_connect": {
  1279  		Name:              "init_connect",
  1280  		Scope:             ScopeGlobal,
  1281  		Dynamic:           true,
  1282  		SetVarHintApplies: false,
  1283  		Type:              InitSystemVariableStringType("init_connect"),
  1284  		Default:           "",
  1285  	},
  1286  	"interactive_timeout": {
  1287  		Name:              "interactive_timeout",
  1288  		Scope:             ScopeBoth,
  1289  		Dynamic:           true,
  1290  		SetVarHintApplies: true,
  1291  		Type:              InitSystemVariableIntType("interactive_timeout", 1, 31536000, false),
  1292  		Default:           int64(28800),
  1293  	},
  1294  	"lower_case_table_names": {
  1295  		Name:              "lower_case_table_names",
  1296  		Scope:             ScopeGlobal,
  1297  		Dynamic:           true,
  1298  		SetVarHintApplies: false,
  1299  		Type:              InitSystemVariableIntType("lower_case_table_names", 0, 2, false),
  1300  		Default:           int64(1),
  1301  	},
  1302  	"net_write_timeout": {
  1303  		Name:              "net_write_timeout",
  1304  		Scope:             ScopeBoth,
  1305  		Dynamic:           true,
  1306  		SetVarHintApplies: false,
  1307  		Type:              InitSystemVariableIntType("net_write_timeout", 1, 31536000, false),
  1308  		Default:           int64(60),
  1309  	},
  1310  	"system_time_zone": {
  1311  		Name:              "system_time_zone",
  1312  		Scope:             ScopeGlobal,
  1313  		Dynamic:           false,
  1314  		SetVarHintApplies: false,
  1315  		Type:              InitSystemVariableStringType("system_time_zone"),
  1316  		Default:           getSystemTimeZone(),
  1317  	},
  1318  	"transaction_isolation": {
  1319  		Name:              "transaction_isolation",
  1320  		Scope:             ScopeBoth,
  1321  		Dynamic:           true,
  1322  		SetVarHintApplies: false,
  1323  		Type:              InitSystemSystemEnumType("transaction_isolation", "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE"),
  1324  		Default:           "REPEATABLE-READ",
  1325  	},
  1326  	"wait_timeout": {
  1327  		Name:              "wait_timeout",
  1328  		Scope:             ScopeBoth,
  1329  		Dynamic:           true,
  1330  		SetVarHintApplies: false,
  1331  		Type:              InitSystemVariableIntType("wait_timeout", 1, 2147483, false),
  1332  		Default:           int64(28800),
  1333  	},
  1334  	"sql_safe_updates": {
  1335  		Name:              "sql_safe_updates",
  1336  		Scope:             ScopeBoth,
  1337  		Dynamic:           true,
  1338  		SetVarHintApplies: false,
  1339  		Type:              InitSystemVariableIntType("sql_safe_updates", 0, 1, false),
  1340  		Default:           int64(0),
  1341  	},
  1342  	"profiling": {
  1343  		Name:              "profiling",
  1344  		Scope:             ScopeBoth,
  1345  		Dynamic:           true,
  1346  		SetVarHintApplies: false,
  1347  		Type:              InitSystemVariableIntType("profiling", 0, 1, false),
  1348  		Default:           int64(0),
  1349  	},
  1350  	"performance_schema": {
  1351  		Name:              "performance_schema",
  1352  		Scope:             ScopeBoth,
  1353  		Dynamic:           true,
  1354  		SetVarHintApplies: false,
  1355  		Type:              InitSystemVariableIntType("performance_schema", 0, 1, false),
  1356  		Default:           int64(0),
  1357  	},
  1358  	"transaction_read_only": {
  1359  		Name:              "transaction_read_only",
  1360  		Scope:             ScopeBoth,
  1361  		Dynamic:           true,
  1362  		SetVarHintApplies: false,
  1363  		Type:              InitSystemVariableIntType("transaction_read_only", 0, 1, false),
  1364  		Default:           int64(0),
  1365  	},
  1366  	"tx_read_only": {
  1367  		Name:              "tx_read_only",
  1368  		Scope:             ScopeBoth,
  1369  		Dynamic:           true,
  1370  		SetVarHintApplies: false,
  1371  		Type:              InitSystemVariableIntType("tx_read_only", 0, 1, false),
  1372  		Default:           int64(0),
  1373  	},
  1374  	"sql_select_limit": {
  1375  		Name:              "sql_select_limit",
  1376  		Scope:             ScopeBoth,
  1377  		Dynamic:           true,
  1378  		SetVarHintApplies: false,
  1379  		Type:              InitSystemVariableUintType("sql_select_limit", 0, 18446744073709551615),
  1380  		Default:           uint64(18446744073709551615),
  1381  	},
  1382  	"save_query_result": {
  1383  		Name:              "save_query_result",
  1384  		Scope:             ScopeBoth,
  1385  		Dynamic:           true,
  1386  		SetVarHintApplies: false,
  1387  		Type:              InitSystemVariableBoolType("save_query_result"),
  1388  		Default:           int64(0),
  1389  	},
  1390  	"query_result_timeout": {
  1391  		Name:              "query_result_timeout",
  1392  		Scope:             ScopeBoth,
  1393  		Dynamic:           true,
  1394  		SetVarHintApplies: false,
  1395  		Type:              InitSystemVariableUintType("query_result_timeout", 0, 18446744073709551615),
  1396  		Default:           uint64(24),
  1397  	},
  1398  	"query_result_maxsize": {
  1399  		Name:              "query_result_maxsize",
  1400  		Scope:             ScopeBoth,
  1401  		Dynamic:           true,
  1402  		SetVarHintApplies: false,
  1403  		Type:              InitSystemVariableUintType("query_result_maxsize", 0, 18446744073709551615),
  1404  		Default:           uint64(100),
  1405  	},
  1406  	//whether TN does primary key uniqueness check against transaction's workspace or not.
  1407  	"mo_pk_check_by_dn": {
  1408  		Name:              "mo_pk_check_by_dn",
  1409  		Scope:             ScopeSession,
  1410  		Dynamic:           true,
  1411  		SetVarHintApplies: false,
  1412  		Type:              InitSystemVariableBoolType("mo_pk_check_by_dn"),
  1413  		Default:           int8(0),
  1414  	},
  1415  	"syspublications": {
  1416  		Name:              "syspublications",
  1417  		Scope:             ScopeBoth,
  1418  		Dynamic:           true,
  1419  		SetVarHintApplies: false,
  1420  		Type:              InitSystemVariableStringType("syspublications"),
  1421  		Default:           "",
  1422  	},
  1423  	"net_buffer_length": {
  1424  		Name:              "net_buffer_length",
  1425  		Scope:             ScopeBoth,
  1426  		Dynamic:           true,
  1427  		SetVarHintApplies: false,
  1428  		Type:              InitSystemVariableIntType("net_buffer_length", 1024, 1048576, false),
  1429  		Default:           int64(16384),
  1430  	},
  1431  	"enable_privilege_cache": {
  1432  		Name:              "enable_privilege_cache",
  1433  		Scope:             ScopeBoth,
  1434  		Dynamic:           true,
  1435  		SetVarHintApplies: false,
  1436  		Type:              InitSystemVariableBoolType("enable_privilege_cache"),
  1437  		Default:           int64(1),
  1438  	},
  1439  	"clear_privilege_cache": {
  1440  		Name:              "clear_privilege_cache",
  1441  		Scope:             ScopeSession,
  1442  		Dynamic:           true,
  1443  		SetVarHintApplies: false,
  1444  		Type:              InitSystemVariableBoolType("clear_privilege_cache"),
  1445  		Default:           int64(0),
  1446  	},
  1447  	"foreign_key_checks": {
  1448  		Name:              "foreign_key_checks",
  1449  		Scope:             ScopeBoth,
  1450  		Dynamic:           true,
  1451  		SetVarHintApplies: false,
  1452  		Type:              InitSystemVariableBoolType("foreign_key_checks"),
  1453  		Default:           int64(1),
  1454  	},
  1455  	"authentication_policy": {
  1456  		Name:              "authentication_policy",
  1457  		Scope:             ScopeGlobal,
  1458  		Dynamic:           true,
  1459  		SetVarHintApplies: false,
  1460  		Type:              InitSystemVariableStringType("authentication_policy"),
  1461  		Default:           "*",
  1462  	},
  1463  	"authentication_windows_log_level": {
  1464  		Name:              "authentication_windows_log_level",
  1465  		Scope:             ScopeGlobal,
  1466  		Dynamic:           false,
  1467  		SetVarHintApplies: false,
  1468  		Type:              InitSystemVariableIntType("authentication_windows_log_level", 0, 4, false),
  1469  		Default:           int64(2),
  1470  	},
  1471  	"authentication_windows_use_principal_name": {
  1472  		Name:              "authentication_windows_use_principal_name",
  1473  		Scope:             ScopeGlobal,
  1474  		Dynamic:           false,
  1475  		SetVarHintApplies: false,
  1476  		Type:              InitSystemVariableBoolType("authentication_windows_use_principal_name"),
  1477  		Default:           int64(1),
  1478  	},
  1479  	"automatic_sp_privileges": {
  1480  		Name:              "automatic_sp_privileges",
  1481  		Scope:             ScopeGlobal,
  1482  		Dynamic:           true,
  1483  		SetVarHintApplies: false,
  1484  		Type:              InitSystemVariableBoolType("automatic_sp_privileges"),
  1485  		Default:           int64(1),
  1486  	},
  1487  	"auto_generate_certs": {
  1488  		Name:              "auto_generate_certs",
  1489  		Scope:             ScopeGlobal,
  1490  		Dynamic:           false,
  1491  		SetVarHintApplies: false,
  1492  		Type:              InitSystemVariableBoolType("auto_generate_certs"),
  1493  		Default:           int64(1),
  1494  	},
  1495  	"avoid_temporal_upgrade": {
  1496  		Name:              "avoid_temporal_upgrade",
  1497  		Scope:             ScopeGlobal,
  1498  		Dynamic:           true,
  1499  		SetVarHintApplies: false,
  1500  		Type:              InitSystemVariableBoolType("avoid_temporal_upgrade"),
  1501  		Default:           int64(0),
  1502  	},
  1503  	"back_log": {
  1504  		Name:              "back_log",
  1505  		Scope:             ScopeGlobal,
  1506  		Dynamic:           false,
  1507  		SetVarHintApplies: false,
  1508  		Type:              InitSystemVariableIntType("back_log", 1, 65535, false),
  1509  		Default:           int64(1),
  1510  	},
  1511  	"basedir": {
  1512  		Name:              "basedir",
  1513  		Scope:             ScopeGlobal,
  1514  		Dynamic:           false,
  1515  		SetVarHintApplies: false,
  1516  		Type:              InitSystemVariableStringType("basedir"),
  1517  		Default:           "",
  1518  	},
  1519  	"big_tables": {
  1520  		Name:              "big_tables",
  1521  		Scope:             ScopeBoth,
  1522  		Dynamic:           true,
  1523  		SetVarHintApplies: false,
  1524  		Type:              InitSystemVariableBoolType("big_tables"),
  1525  		Default:           int64(0),
  1526  	},
  1527  	"bind_address": {
  1528  		Name:              "bind_address",
  1529  		Scope:             ScopeGlobal,
  1530  		Dynamic:           false,
  1531  		SetVarHintApplies: false,
  1532  		Type:              InitSystemVariableStringType("bind_address"),
  1533  		Default:           "*",
  1534  	},
  1535  	"block_encryption_mode": {
  1536  		Name:              "block_encryption_mode",
  1537  		Scope:             ScopeBoth,
  1538  		Dynamic:           true,
  1539  		SetVarHintApplies: false,
  1540  		Type:              InitSystemVariableStringType("block_encryption_mode"),
  1541  		Default:           "aes-128-ecb",
  1542  	},
  1543  	"build_id": {
  1544  		Name:              "build_id",
  1545  		Scope:             ScopeGlobal,
  1546  		Dynamic:           false,
  1547  		SetVarHintApplies: false,
  1548  		Type:              InitSystemVariableStringType("build_id"),
  1549  		Default:           "",
  1550  	},
  1551  	"bulk_insert_buffer_size": {
  1552  		Name:              "bulk_insert_buffer_size",
  1553  		Scope:             ScopeBoth,
  1554  		Dynamic:           true,
  1555  		SetVarHintApplies: true,
  1556  		Type:              InitSystemVariableIntType("bulk_insert_buffer_size", 0, 4294967295, false),
  1557  		Default:           int64(8388608),
  1558  	},
  1559  	"caching_sha2_password_digest_rounds": {
  1560  		Name:              "caching_sha2_password_digest_rounds",
  1561  		Scope:             ScopeGlobal,
  1562  		Dynamic:           false,
  1563  		SetVarHintApplies: false,
  1564  		Type:              InitSystemVariableIntType("caching_sha2_password_digest_rounds", 5000, 4095000, false),
  1565  		Default:           int64(5000),
  1566  	},
  1567  	"caching_sha2_password_auto_generate_rsa_keys": {
  1568  		Name:              "caching_sha2_password_auto_generate_rsa_keys",
  1569  		Scope:             ScopeGlobal,
  1570  		Dynamic:           false,
  1571  		SetVarHintApplies: false,
  1572  		Type:              InitSystemVariableBoolType("caching_sha2_password_auto_generate_rsa_keys"),
  1573  		Default:           int64(1),
  1574  	},
  1575  	"caching_sha2_password_private_key_path": {
  1576  		Name:              "caching_sha2_password_private_key_path",
  1577  		Scope:             ScopeGlobal,
  1578  		Dynamic:           false,
  1579  		SetVarHintApplies: false,
  1580  		Type:              InitSystemVariableStringType("caching_sha2_password_private_key_path"),
  1581  		Default:           "private_key.pem",
  1582  	},
  1583  	"character_set_filesystem": {
  1584  		Name:              "character_set_filesystem",
  1585  		Scope:             ScopeBoth,
  1586  		Dynamic:           true,
  1587  		SetVarHintApplies: false,
  1588  		Type:              InitSystemVariableStringType("character_set_filesystem"),
  1589  		Default:           "binary",
  1590  	},
  1591  	"character_set_system": {
  1592  		Name:              "character_set_system",
  1593  		Scope:             ScopeGlobal,
  1594  		Dynamic:           false,
  1595  		SetVarHintApplies: false,
  1596  		Type:              InitSystemVariableStringType("character_set_system"),
  1597  		Default:           "utf8mb3",
  1598  	},
  1599  	"character_sets_dir": {
  1600  		Name:              "character_sets_dir",
  1601  		Scope:             ScopeGlobal,
  1602  		Dynamic:           false,
  1603  		SetVarHintApplies: false,
  1604  		Type:              InitSystemVariableStringType("character_sets_dir"),
  1605  		Default:           "",
  1606  	},
  1607  	"check_proxy_users": {
  1608  		Name:              "check_proxy_users",
  1609  		Scope:             ScopeGlobal,
  1610  		Dynamic:           true,
  1611  		SetVarHintApplies: false,
  1612  		Type:              InitSystemVariableBoolType("check_proxy_users"),
  1613  		Default:           int64(0),
  1614  	},
  1615  	"collation_database": {
  1616  		Name:              "collation_database",
  1617  		Scope:             ScopeBoth,
  1618  		Dynamic:           true,
  1619  		SetVarHintApplies: false,
  1620  		Type:              InitSystemVariableStringType("collation_database"),
  1621  		Default:           "utf8mb4_0900_ai_ci",
  1622  	},
  1623  	"concurrent_insert": {
  1624  		Name:              "concurrent_insert",
  1625  		Scope:             ScopeGlobal,
  1626  		Dynamic:           true,
  1627  		SetVarHintApplies: false,
  1628  		Type:              InitSystemSystemEnumType("concurrent_insert", "NEVER", "AUTO", "ALWAYS", "0", "1", "2"),
  1629  		Default:           "AUTO",
  1630  	},
  1631  	"connect_timeout": {
  1632  		Name:              "connect_timeout",
  1633  		Scope:             ScopeGlobal,
  1634  		Dynamic:           true,
  1635  		SetVarHintApplies: false,
  1636  		Type:              InitSystemVariableIntType("connect_timeout", 2, 31536000, false),
  1637  		Default:           int64(10),
  1638  	},
  1639  	"connection_memory_chunk_size": {
  1640  		Name:              "connection_memory_chunk_size",
  1641  		Scope:             ScopeBoth,
  1642  		Dynamic:           true,
  1643  		SetVarHintApplies: false,
  1644  		Type:              InitSystemVariableIntType("connection_memory_chunk_size", 0, 536870912, false),
  1645  		Default:           int64(8192),
  1646  	},
  1647  	"connection_memory_limit": {
  1648  		Name:              "connection_memory_limit",
  1649  		Scope:             ScopeBoth,
  1650  		Dynamic:           true,
  1651  		SetVarHintApplies: false,
  1652  		Type:              InitSystemVariableIntType("connection_memory_limit", 0, math.MaxInt64, false),
  1653  		Default:           int64(math.MaxInt64),
  1654  	},
  1655  	"core_file": {
  1656  		Name:              "core_file",
  1657  		Scope:             ScopeGlobal,
  1658  		Dynamic:           false,
  1659  		SetVarHintApplies: false,
  1660  		Type:              InitSystemVariableBoolType("core_file"),
  1661  		Default:           int64(0),
  1662  	},
  1663  	"create_admin_listener_thread": {
  1664  		Name:              "create_admin_listener_thread",
  1665  		Scope:             ScopeGlobal,
  1666  		Dynamic:           false,
  1667  		SetVarHintApplies: false,
  1668  		Type:              InitSystemVariableBoolType("create_admin_listener_thread"),
  1669  		Default:           int64(0),
  1670  	},
  1671  	"cte_max_recursion_depth": {
  1672  		Name:              "cte_max_recursion_depth",
  1673  		Scope:             ScopeBoth,
  1674  		Dynamic:           true,
  1675  		SetVarHintApplies: false,
  1676  		Type:              InitSystemVariableIntType("cte_max_recursion_depth", 0, 4294967295, false),
  1677  		Default:           int64(1000),
  1678  	},
  1679  	"datadir": {
  1680  		Name:              "datadir",
  1681  		Scope:             ScopeGlobal,
  1682  		Dynamic:           false,
  1683  		SetVarHintApplies: false,
  1684  		Type:              InitSystemVariableStringType("datadir"),
  1685  		Default:           "",
  1686  	},
  1687  	"debug": {
  1688  		Name:              "debug",
  1689  		Scope:             ScopeBoth,
  1690  		Dynamic:           true,
  1691  		SetVarHintApplies: false,
  1692  		Type:              InitSystemVariableStringType("debug"),
  1693  		Default:           "/tmp/mysqld.trace",
  1694  	},
  1695  	"debug_sync": {
  1696  		Name:              "debug_sync",
  1697  		Scope:             ScopeSession,
  1698  		Dynamic:           true,
  1699  		SetVarHintApplies: false,
  1700  		Type:              InitSystemVariableStringType("debug_sync"),
  1701  		Default:           "",
  1702  	},
  1703  	"default_authentication_plugin": {
  1704  		Name:              "default_authentication_plugin",
  1705  		Scope:             ScopeGlobal,
  1706  		Dynamic:           false,
  1707  		SetVarHintApplies: false,
  1708  		Type:              InitSystemSystemEnumType("default_authentication_plugin", "mysql_native_password", "sha256_password", "caching_sha2_password"),
  1709  		Default:           "caching_sha2_password",
  1710  	},
  1711  	"default_collation_for_utf8mb4": {
  1712  		Name:              "default_collation_for_utf8mb4",
  1713  		Scope:             ScopeBoth,
  1714  		Dynamic:           true,
  1715  		SetVarHintApplies: false,
  1716  		Type:              InitSystemSystemEnumType("default_collation_for_utf8mb4", "utf8mb4_0900_ai_ci", "utf8mb4_general_ci"),
  1717  		Default:           "utf8mb4_0900_ai_ci",
  1718  	},
  1719  	"default_password_lifetime": {
  1720  		Name:              "default_password_lifetime",
  1721  		Scope:             ScopeGlobal,
  1722  		Dynamic:           true,
  1723  		SetVarHintApplies: false,
  1724  		Type:              InitSystemVariableIntType("default_password_lifetime", 0, 65535, false),
  1725  		Default:           int64(0),
  1726  	},
  1727  	"default_storage_engine": {
  1728  		Name:              "default_storage_engine",
  1729  		Scope:             ScopeBoth,
  1730  		Dynamic:           true,
  1731  		SetVarHintApplies: false,
  1732  		Type:              InitSystemSystemEnumType("default_storage_engine", "InnoDB"),
  1733  		Default:           "InnoDB",
  1734  	},
  1735  	"default_table_encryption": {
  1736  		Name:              "default_table_encryption",
  1737  		Scope:             ScopeBoth,
  1738  		Dynamic:           true,
  1739  		SetVarHintApplies: true,
  1740  		Type:              InitSystemVariableBoolType("default_table_encryption"),
  1741  		Default:           int64(0),
  1742  	},
  1743  	"default_tmp_storage_engine": {
  1744  		Name:              "default_tmp_storage_engine",
  1745  		Scope:             ScopeBoth,
  1746  		Dynamic:           true,
  1747  		SetVarHintApplies: true,
  1748  		Type:              InitSystemSystemEnumType("default_tmp_storage_engine", "InnoDB"),
  1749  		Default:           "InnoDB",
  1750  	},
  1751  	"default_week_format": {
  1752  		Name:              "default_week_format",
  1753  		Scope:             ScopeBoth,
  1754  		Dynamic:           true,
  1755  		SetVarHintApplies: false,
  1756  		Type:              InitSystemVariableIntType("default_week_format", 0, 7, false),
  1757  		Default:           int64(0),
  1758  	},
  1759  	"delay_key_write": {
  1760  		Name:              "delay_key_write",
  1761  		Scope:             ScopeGlobal,
  1762  		Dynamic:           true,
  1763  		SetVarHintApplies: false,
  1764  		Type:              InitSystemSystemEnumType("delay_key_write", "OFF", "ON", "ALL"),
  1765  		Default:           "ON",
  1766  	},
  1767  	"delayed_insert_limit": {
  1768  		Name:              "delayed_insert_limit",
  1769  		Scope:             ScopeGlobal,
  1770  		Dynamic:           true,
  1771  		SetVarHintApplies: false,
  1772  		Type:              InitSystemVariableIntType("delayed_insert_limit", 1, math.MaxInt64, false),
  1773  		Default:           int64(100),
  1774  	},
  1775  	"delayed_insert_timeout": {
  1776  		Name:              "delayed_insert_timeout",
  1777  		Scope:             ScopeGlobal,
  1778  		Dynamic:           true,
  1779  		SetVarHintApplies: false,
  1780  		Type:              InitSystemVariableIntType("delayed_insert_timeout", 1, 31536000, false),
  1781  		Default:           int64(300),
  1782  	},
  1783  	"delayed_queue_size": {
  1784  		Name:              "delayed_queue_size",
  1785  		Scope:             ScopeGlobal,
  1786  		Dynamic:           true,
  1787  		SetVarHintApplies: false,
  1788  		Type:              InitSystemVariableIntType("delayed_queue_size", 1, math.MaxInt64, false),
  1789  		Default:           int64(1000),
  1790  	},
  1791  	"disabled_storage_engines": {
  1792  		Name:              "disabled_storage_engines",
  1793  		Scope:             ScopeGlobal,
  1794  		Dynamic:           false,
  1795  		SetVarHintApplies: false,
  1796  		Type:              InitSystemVariableStringType("disabled_storage_engines"),
  1797  		Default:           "",
  1798  	},
  1799  	"disconnect_on_expired_password": {
  1800  		Name:              "disconnect_on_expired_password",
  1801  		Scope:             ScopeGlobal,
  1802  		Dynamic:           false,
  1803  		SetVarHintApplies: false,
  1804  		Type:              InitSystemVariableBoolType("disconnect_on_expired_password"),
  1805  		Default:           int64(1),
  1806  	},
  1807  	"div_precision_increment": {
  1808  		Name:              "div_precision_increment",
  1809  		Scope:             ScopeBoth,
  1810  		Dynamic:           true,
  1811  		SetVarHintApplies: true,
  1812  		Type:              InitSystemVariableIntType("div_precision_increment", 0, 30, false),
  1813  		Default:           int64(4),
  1814  	},
  1815  	"end_markers_in_json": {
  1816  		Name:              "end_markers_in_json",
  1817  		Scope:             ScopeBoth,
  1818  		Dynamic:           true,
  1819  		SetVarHintApplies: true,
  1820  		Type:              InitSystemVariableBoolType("end_markers_in_json"),
  1821  		Default:           int64(0),
  1822  	},
  1823  	"eq_range_index_dive_limit": {
  1824  		Name:              "eq_range_index_dive_limit",
  1825  		Scope:             ScopeBoth,
  1826  		Dynamic:           true,
  1827  		SetVarHintApplies: true,
  1828  		Type:              InitSystemVariableIntType("eq_range_index_dive_limit", 0, 4294967295, false),
  1829  		Default:           int64(0),
  1830  	},
  1831  	"event_scheduler": {
  1832  		Name:              "event_scheduler",
  1833  		Scope:             ScopeGlobal,
  1834  		Dynamic:           true,
  1835  		SetVarHintApplies: false,
  1836  		Type:              InitSystemSystemEnumType("event_scheduler", "ON", "OFF", "DISABLED"),
  1837  		Default:           "ON",
  1838  	},
  1839  	"explain_format": {
  1840  		Name:              "explain_format",
  1841  		Scope:             ScopeBoth,
  1842  		Dynamic:           true,
  1843  		SetVarHintApplies: false,
  1844  		Type:              InitSystemSystemEnumType("explain_format", "DEFAULT", "TRADITIONAL", "JSON", "TREE"),
  1845  		Default:           "TRADITIONAL",
  1846  	},
  1847  	"explicit_defaults_for_timestamp": {
  1848  		Name:              "explicit_defaults_for_timestamp",
  1849  		Scope:             ScopeBoth,
  1850  		Dynamic:           true,
  1851  		SetVarHintApplies: false,
  1852  		Type:              InitSystemVariableBoolType("explicit_defaults_for_timestamp"),
  1853  		Default:           int64(1),
  1854  	},
  1855  	"external_user": {
  1856  		Name:              "external_user",
  1857  		Scope:             ScopeSession,
  1858  		Dynamic:           false,
  1859  		SetVarHintApplies: false,
  1860  		Type:              InitSystemVariableStringType("external_user"),
  1861  		Default:           "",
  1862  	},
  1863  	"flush": {
  1864  		Name:              "flush",
  1865  		Scope:             ScopeGlobal,
  1866  		Dynamic:           true,
  1867  		SetVarHintApplies: false,
  1868  		Type:              InitSystemVariableBoolType("flush"),
  1869  		Default:           int64(0),
  1870  	},
  1871  	"flush_time": {
  1872  		Name:              "flush_time",
  1873  		Scope:             ScopeGlobal,
  1874  		Dynamic:           true,
  1875  		SetVarHintApplies: false,
  1876  		Type:              InitSystemVariableIntType("flush_time", 0, 31536000, false),
  1877  		Default:           int64(0),
  1878  	},
  1879  	"ft_boolean_syntax": {
  1880  		Name:              "ft_boolean_syntax",
  1881  		Scope:             ScopeGlobal,
  1882  		Dynamic:           true,
  1883  		SetVarHintApplies: false,
  1884  		Type:              InitSystemVariableStringType("ft_boolean_syntax"),
  1885  		Default:           "+ -><()~*:\"\"&|",
  1886  	},
  1887  	"ft_max_word_len": {
  1888  		Name:              "ft_max_word_len",
  1889  		Scope:             ScopeGlobal,
  1890  		Dynamic:           false,
  1891  		SetVarHintApplies: false,
  1892  		Type:              InitSystemVariableIntType("ft_max_word_len", 10, 84, false),
  1893  		Default:           int64(84),
  1894  	},
  1895  	"ft_min_word_len": {
  1896  		Name:              "ft_max_word_len",
  1897  		Scope:             ScopeGlobal,
  1898  		Dynamic:           false,
  1899  		SetVarHintApplies: false,
  1900  		Type:              InitSystemVariableIntType("ft_min_word_len", 1, 82, false),
  1901  		Default:           int64(4),
  1902  	},
  1903  	"ft_query_expansion_limit": {
  1904  		Name:              "ft_query_expansion_limit",
  1905  		Scope:             ScopeGlobal,
  1906  		Dynamic:           false,
  1907  		SetVarHintApplies: false,
  1908  		Type:              InitSystemVariableIntType("ft_query_expansion_limit", 0, 1000, false),
  1909  		Default:           int64(20),
  1910  	},
  1911  	"ft_stopword_file": {
  1912  		Name:              "ft_stopword_file",
  1913  		Scope:             ScopeGlobal,
  1914  		Dynamic:           false,
  1915  		SetVarHintApplies: false,
  1916  		Type:              InitSystemVariableStringType("ft_stopword_file"),
  1917  		Default:           "",
  1918  	},
  1919  	"general_log": {
  1920  		Name:              "general_log",
  1921  		Scope:             ScopeGlobal,
  1922  		Dynamic:           true,
  1923  		SetVarHintApplies: false,
  1924  		Type:              InitSystemVariableBoolType("general_log"),
  1925  		Default:           int64(0),
  1926  	},
  1927  	"general_log_file": {
  1928  		Name:              "general_log_file",
  1929  		Scope:             ScopeGlobal,
  1930  		Dynamic:           true,
  1931  		SetVarHintApplies: false,
  1932  		Type:              InitSystemVariableStringType("general_log_file"),
  1933  		Default:           "host_name.log",
  1934  	},
  1935  	"generated_random_password_length": {
  1936  		Name:              "generated_random_password_length",
  1937  		Scope:             ScopeBoth,
  1938  		Dynamic:           true,
  1939  		SetVarHintApplies: false,
  1940  		Type:              InitSystemVariableIntType("generated_random_password_length", 5, 255, false),
  1941  		Default:           int64(20),
  1942  	},
  1943  	"global_connection_memory_limit": {
  1944  		Name:              "global_connection_memory_limit",
  1945  		Scope:             ScopeGlobal,
  1946  		Dynamic:           true,
  1947  		SetVarHintApplies: false,
  1948  		Type:              InitSystemVariableIntType("global_connection_memory_limit", 16777216, math.MaxInt64, false),
  1949  		Default:           int64(math.MaxInt64),
  1950  	},
  1951  	"global_connection_memory_tracking": {
  1952  		Name:              "global_connection_memory_tracking",
  1953  		Scope:             ScopeBoth,
  1954  		Dynamic:           true,
  1955  		SetVarHintApplies: false,
  1956  		Type:              InitSystemVariableBoolType("global_connection_memory_tracking"),
  1957  		Default:           int64(0),
  1958  	},
  1959  	"group_concat_max_len": {
  1960  		Name:              "group_concat_max_len",
  1961  		Scope:             ScopeBoth,
  1962  		Dynamic:           true,
  1963  		SetVarHintApplies: true,
  1964  		Type:              InitSystemVariableIntType("group_concat_max_len", 4, math.MaxInt64, false),
  1965  		Default:           int64(4),
  1966  	},
  1967  	"have_ssl": {
  1968  		Name:              "have_ssl",
  1969  		Scope:             ScopeGlobal,
  1970  		Dynamic:           false,
  1971  		SetVarHintApplies: false,
  1972  		Type:              InitSystemVariableStringType("have_ssl"),
  1973  		Default:           "YES",
  1974  	},
  1975  	"have_statement_timeout": {
  1976  		Name:              "have_statement_timeout",
  1977  		Scope:             ScopeGlobal,
  1978  		Dynamic:           false,
  1979  		SetVarHintApplies: false,
  1980  		Type:              InitSystemVariableBoolType("have_statement_timeout"),
  1981  		Default:           int64(0),
  1982  	},
  1983  	"histogram_generation_max_mem_size": {
  1984  		Name:              "histogram_generation_max_mem_size",
  1985  		Scope:             ScopeBoth,
  1986  		Dynamic:           true,
  1987  		SetVarHintApplies: false,
  1988  		Type:              InitSystemVariableIntType("histogram_generation_max_mem_size", 1000000, math.MaxInt64, false),
  1989  		Default:           int64(1000000),
  1990  	},
  1991  	"host_cache_size": {
  1992  		Name:              "host_cache_size",
  1993  		Scope:             ScopeGlobal,
  1994  		Dynamic:           true,
  1995  		SetVarHintApplies: false,
  1996  		Type:              InitSystemVariableIntType("host_cache_size", 0, 65536, false),
  1997  		Default:           int64(0),
  1998  	},
  1999  	"hostname": {
  2000  		Name:              "hostname",
  2001  		Scope:             ScopeGlobal,
  2002  		Dynamic:           false,
  2003  		SetVarHintApplies: false,
  2004  		Type:              InitSystemVariableStringType("hostname"),
  2005  		Default:           "",
  2006  	},
  2007  	"information_schema_stats_expiry": {
  2008  		Name:              "information_schema_stats_expiry",
  2009  		Scope:             ScopeGlobal,
  2010  		Dynamic:           true,
  2011  		SetVarHintApplies: false,
  2012  		Type:              InitSystemVariableIntType("information_schema_stats_expiry", 0, 86400, false),
  2013  		Default:           int64(86400),
  2014  	},
  2015  	"init_file": {
  2016  		Name:              "init_file",
  2017  		Scope:             ScopeGlobal,
  2018  		Dynamic:           false,
  2019  		SetVarHintApplies: false,
  2020  		Type:              InitSystemVariableStringType("init_file"),
  2021  		Default:           "",
  2022  	},
  2023  	"internal_tmp_disk_storage_engine": {
  2024  		Name:              "internal_tmp_disk_storage_engine",
  2025  		Scope:             ScopeGlobal,
  2026  		Dynamic:           true,
  2027  		SetVarHintApplies: false,
  2028  		Type:              InitSystemSystemEnumType("internal_tmp_disk_storage_engine", "MYISAM", "INNODB"),
  2029  		Default:           "INNODB",
  2030  	},
  2031  	"internal_tmp_mem_storage_engine": {
  2032  		Name:              "internal_tmp_mem_storage_engine",
  2033  		Scope:             ScopeBoth,
  2034  		Dynamic:           true,
  2035  		SetVarHintApplies: true,
  2036  		Type:              InitSystemSystemEnumType("internal_tmp_mem_storage_engine", "MEMORY", "TempTable"),
  2037  		Default:           "TempTable",
  2038  	},
  2039  	"join_buffer_size": {
  2040  		Name:              "join_buffer_size",
  2041  		Scope:             ScopeBoth,
  2042  		Dynamic:           true,
  2043  		SetVarHintApplies: true,
  2044  		Type:              InitSystemVariableIntType("join_buffer_size", 128, 4294967168, false),
  2045  		Default:           int64(262144),
  2046  	},
  2047  	"keep_files_on_create": {
  2048  		Name:              "keep_files_on_create",
  2049  		Scope:             ScopeBoth,
  2050  		Dynamic:           true,
  2051  		SetVarHintApplies: false,
  2052  		Type:              InitSystemVariableBoolType("join_buffer_size"),
  2053  		Default:           int64(0),
  2054  	},
  2055  	"key_buffer_size": {
  2056  		Name:              "key_buffer_size",
  2057  		Scope:             ScopeGlobal,
  2058  		Dynamic:           true,
  2059  		SetVarHintApplies: false,
  2060  		Type:              InitSystemVariableIntType("key_buffer_size", 0, 4294967295, false),
  2061  		Default:           int64(8388608),
  2062  	},
  2063  	"key_cache_age_threshold": {
  2064  		Name:              "key_cache_age_threshold",
  2065  		Scope:             ScopeGlobal,
  2066  		Dynamic:           true,
  2067  		SetVarHintApplies: false,
  2068  		Type:              InitSystemVariableIntType("key_cache_age_threshold", 100, 4294967295, false),
  2069  		Default:           int64(300),
  2070  	},
  2071  	"key_cache_block_size": {
  2072  		Name:              "key_cache_block_size",
  2073  		Scope:             ScopeGlobal,
  2074  		Dynamic:           true,
  2075  		SetVarHintApplies: false,
  2076  		Type:              InitSystemVariableIntType("key_cache_block_size", 512, 16384, false),
  2077  		Default:           int64(1024),
  2078  	},
  2079  	"key_cache_division_limit": {
  2080  		Name:              "key_cache_division_limit",
  2081  		Scope:             ScopeGlobal,
  2082  		Dynamic:           true,
  2083  		SetVarHintApplies: false,
  2084  		Type:              InitSystemVariableIntType("key_cache_division_limit", 1, 100, false),
  2085  		Default:           int64(100),
  2086  	},
  2087  	"large_files_support": {
  2088  		Name:              "large_files_support",
  2089  		Scope:             ScopeGlobal,
  2090  		Dynamic:           false,
  2091  		SetVarHintApplies: false,
  2092  		Type:              InitSystemVariableBoolType("large_files_support"),
  2093  		Default:           int64(0),
  2094  	},
  2095  	"large_pages": {
  2096  		Name:              "large_pages",
  2097  		Scope:             ScopeGlobal,
  2098  		Dynamic:           false,
  2099  		SetVarHintApplies: false,
  2100  		Type:              InitSystemVariableBoolType("large_pages"),
  2101  		Default:           int64(0),
  2102  	},
  2103  	"large_page_size": {
  2104  		Name:              "large_page_size",
  2105  		Scope:             ScopeGlobal,
  2106  		Dynamic:           false,
  2107  		SetVarHintApplies: false,
  2108  		Type:              InitSystemVariableIntType("large_page_size", 0, 65535, false),
  2109  		Default:           int64(0),
  2110  	},
  2111  	"lc_messages": {
  2112  		Name:              "lc_messages",
  2113  		Scope:             ScopeBoth,
  2114  		Dynamic:           true,
  2115  		SetVarHintApplies: false,
  2116  		Type:              InitSystemVariableStringType("lc_messages"),
  2117  		Default:           "en_US",
  2118  	},
  2119  	"lc_messages_dir": {
  2120  		Name:              "lc_messages_dir",
  2121  		Scope:             ScopeGlobal,
  2122  		Dynamic:           false,
  2123  		SetVarHintApplies: false,
  2124  		Type:              InitSystemVariableStringType("lc_messages_dir"),
  2125  		Default:           "",
  2126  	},
  2127  	"lc_time_names": {
  2128  		Name:              "lc_time_names",
  2129  		Scope:             ScopeBoth,
  2130  		Dynamic:           true,
  2131  		SetVarHintApplies: false,
  2132  		Type:              InitSystemVariableStringType("lc_time_names"),
  2133  		Default:           "",
  2134  	},
  2135  	"local_infile": {
  2136  		Name:              "local_infile",
  2137  		Scope:             ScopeGlobal,
  2138  		Dynamic:           true,
  2139  		SetVarHintApplies: false,
  2140  		Type:              InitSystemVariableBoolType("local_infile"),
  2141  		Default:           int64(0),
  2142  	},
  2143  	"lock_wait_timeout": {
  2144  		Name:              "lock_wait_timeout",
  2145  		Scope:             ScopeBoth,
  2146  		Dynamic:           true,
  2147  		SetVarHintApplies: true,
  2148  		Type:              InitSystemVariableIntType("lock_wait_timeout", 1, 31536000, false),
  2149  		Default:           int64(31536000),
  2150  	},
  2151  	"locked_in_memory": {
  2152  		Name:              "locked_in_memory",
  2153  		Scope:             ScopeGlobal,
  2154  		Dynamic:           false,
  2155  		SetVarHintApplies: false,
  2156  		Type:              InitSystemVariableBoolType("locked_in_memory"),
  2157  		Default:           int64(0),
  2158  	},
  2159  	"log_error": {
  2160  		Name:              "log_error",
  2161  		Scope:             ScopeGlobal,
  2162  		Dynamic:           false,
  2163  		SetVarHintApplies: false,
  2164  		Type:              InitSystemVariableStringType("log_error"),
  2165  		Default:           "",
  2166  	},
  2167  	"log_error_services": {
  2168  		Name:              "log_error_services",
  2169  		Scope:             ScopeGlobal,
  2170  		Dynamic:           true,
  2171  		SetVarHintApplies: false,
  2172  		Type:              InitSystemVariableStringType("log_error_services"),
  2173  		Default:           "log_filter_internal",
  2174  	},
  2175  	"log_error_suppression_list": {
  2176  		Name:              "log_error_suppression_list",
  2177  		Scope:             ScopeGlobal,
  2178  		Dynamic:           true,
  2179  		SetVarHintApplies: false,
  2180  		Type:              InitSystemVariableStringType("log_error_suppression_list"),
  2181  		Default:           "",
  2182  	},
  2183  	"log_error_verbosity": {
  2184  		Name:              "log_error_verbosity",
  2185  		Scope:             ScopeGlobal,
  2186  		Dynamic:           true,
  2187  		SetVarHintApplies: false,
  2188  		Type:              InitSystemVariableIntType("log_error_verbosity", 1, 3, false),
  2189  		Default:           int64(2),
  2190  	},
  2191  	"log_output": {
  2192  		Name:              "log_output",
  2193  		Scope:             ScopeGlobal,
  2194  		Dynamic:           true,
  2195  		SetVarHintApplies: false,
  2196  		Type:              InitSystemSystemEnumType("log_output", "TABLE", "FILE", "NONE"),
  2197  		Default:           "FILE",
  2198  	},
  2199  	"log_queries_not_using_indexes": {
  2200  		Name:              "log_queries_not_using_indexes",
  2201  		Scope:             ScopeGlobal,
  2202  		Dynamic:           true,
  2203  		SetVarHintApplies: false,
  2204  		Type:              InitSystemVariableBoolType("log_queries_not_using_indexes"),
  2205  		Default:           int64(0),
  2206  	},
  2207  	"log_raw": {
  2208  		Name:              "log_raw",
  2209  		Scope:             ScopeGlobal,
  2210  		Dynamic:           true,
  2211  		SetVarHintApplies: false,
  2212  		Type:              InitSystemVariableBoolType("log_raw"),
  2213  		Default:           int64(0),
  2214  	},
  2215  	"log_slow_admin_statements": {
  2216  		Name:              "log_slow_admin_statements",
  2217  		Scope:             ScopeGlobal,
  2218  		Dynamic:           true,
  2219  		SetVarHintApplies: false,
  2220  		Type:              InitSystemVariableBoolType("log_slow_admin_statements"),
  2221  		Default:           int64(0),
  2222  	},
  2223  	"log_slow_extra": {
  2224  		Name:              "log_slow_extra",
  2225  		Scope:             ScopeGlobal,
  2226  		Dynamic:           true,
  2227  		SetVarHintApplies: false,
  2228  		Type:              InitSystemVariableBoolType("log_slow_extra"),
  2229  		Default:           int64(0),
  2230  	},
  2231  	"log_syslog": {
  2232  		Name:              "log_syslog",
  2233  		Scope:             ScopeGlobal,
  2234  		Dynamic:           true,
  2235  		SetVarHintApplies: false,
  2236  		Type:              InitSystemVariableBoolType("log_syslog"),
  2237  		Default:           int64(1),
  2238  	},
  2239  	"log_syslog_facility": {
  2240  		Name:              "log_syslog_facility",
  2241  		Scope:             ScopeGlobal,
  2242  		Dynamic:           true,
  2243  		SetVarHintApplies: false,
  2244  		Type:              InitSystemVariableStringType("log_syslog_facility"),
  2245  		Default:           "daemon",
  2246  	},
  2247  	"log_syslog_include_pid": {
  2248  		Name:              "log_syslog_include_pid",
  2249  		Scope:             ScopeGlobal,
  2250  		Dynamic:           true,
  2251  		SetVarHintApplies: false,
  2252  		Type:              InitSystemVariableBoolType("log_syslog_include_pid"),
  2253  		Default:           int64(1),
  2254  	},
  2255  	"log_syslog_tag": {
  2256  		Name:              "log_syslog_tag",
  2257  		Scope:             ScopeGlobal,
  2258  		Dynamic:           true,
  2259  		SetVarHintApplies: false,
  2260  		Type:              InitSystemVariableStringType("log_syslog_tag"),
  2261  		Default:           "",
  2262  	},
  2263  	"log_timestamps": {
  2264  		Name:              "log_timestamps",
  2265  		Scope:             ScopeGlobal,
  2266  		Dynamic:           true,
  2267  		SetVarHintApplies: false,
  2268  		Type:              InitSystemSystemEnumType("log_timestamps", "UTC", "SYSTEM"),
  2269  		Default:           "UTC",
  2270  	},
  2271  	"log_throttle_queries_not_using_indexes": {
  2272  		Name:              "log_throttle_queries_not_using_indexes",
  2273  		Scope:             ScopeGlobal,
  2274  		Dynamic:           true,
  2275  		SetVarHintApplies: false,
  2276  		Type:              InitSystemVariableIntType("log_throttle_queries_not_using_indexes", 0, 4294967295, false),
  2277  		Default:           int64(0),
  2278  	},
  2279  	"long_query_time": {
  2280  		Name:              "long_query_time",
  2281  		Scope:             ScopeBoth,
  2282  		Dynamic:           true,
  2283  		SetVarHintApplies: false,
  2284  		Type:              InitSystemVariableDoubleType("long_query_time", 0, 31536000),
  2285  		Default:           float64(10),
  2286  	},
  2287  	"low_priority_updates": {
  2288  		Name:              "low_priority_updates",
  2289  		Scope:             ScopeBoth,
  2290  		Dynamic:           true,
  2291  		SetVarHintApplies: false,
  2292  		Type:              InitSystemVariableBoolType("low_priority_updates"),
  2293  		Default:           int64(0),
  2294  	},
  2295  	"lower_case_file_system": {
  2296  		Name:              "lower_case_file_system",
  2297  		Scope:             ScopeGlobal,
  2298  		Dynamic:           false,
  2299  		SetVarHintApplies: false,
  2300  		Type:              InitSystemVariableBoolType("lower_case_file_system"),
  2301  		Default:           int64(0),
  2302  	},
  2303  	"mandatory_roles": {
  2304  		Name:              "mandatory_roles",
  2305  		Scope:             ScopeGlobal,
  2306  		Dynamic:           true,
  2307  		SetVarHintApplies: false,
  2308  		Type:              InitSystemVariableStringType("mandatory_roles"),
  2309  		Default:           "",
  2310  	},
  2311  	"max_connect_errors": {
  2312  		Name:              "max_connect_errors",
  2313  		Scope:             ScopeGlobal,
  2314  		Dynamic:           true,
  2315  		SetVarHintApplies: false,
  2316  		Type:              InitSystemVariableIntType("max_connect_errors", 1, 4294967295, false),
  2317  		Default:           int64(100),
  2318  	},
  2319  	"max_connections": {
  2320  		Name:              "max_connections",
  2321  		Scope:             ScopeGlobal,
  2322  		Dynamic:           true,
  2323  		SetVarHintApplies: false,
  2324  		Type:              InitSystemVariableIntType("max_connections", 1, 100000, false),
  2325  		Default:           int64(151),
  2326  	},
  2327  	"max_delayed_threads": {
  2328  		Name:              "max_delayed_threads",
  2329  		Scope:             ScopeBoth,
  2330  		Dynamic:           true,
  2331  		SetVarHintApplies: false,
  2332  		Type:              InitSystemVariableIntType("max_delayed_threads", 0, 16384, false),
  2333  		Default:           int64(20),
  2334  	},
  2335  	"max_digest_length": {
  2336  		Name:              "max_digest_length",
  2337  		Scope:             ScopeGlobal,
  2338  		Dynamic:           false,
  2339  		SetVarHintApplies: false,
  2340  		Type:              InitSystemVariableIntType("max_digest_length", 0, 1048576, false),
  2341  		Default:           int64(1024),
  2342  	},
  2343  	"max_error_count": {
  2344  		Name:              "max_error_count",
  2345  		Scope:             ScopeBoth,
  2346  		Dynamic:           true,
  2347  		SetVarHintApplies: true,
  2348  		Type:              InitSystemVariableIntType("max_error_count", 0, 65535, false),
  2349  		Default:           int64(1024),
  2350  	},
  2351  	"max_execution_time": {
  2352  		Name:              "max_execution_time",
  2353  		Scope:             ScopeBoth,
  2354  		Dynamic:           true,
  2355  		SetVarHintApplies: true,
  2356  		Type:              InitSystemVariableIntType("max_execution_time", 0, 4294967295, false),
  2357  		Default:           int64(0),
  2358  	},
  2359  	"max_heap_table_size": {
  2360  		Name:              "max_heap_table_size",
  2361  		Scope:             ScopeBoth,
  2362  		Dynamic:           true,
  2363  		SetVarHintApplies: true,
  2364  		Type:              InitSystemVariableIntType("max_heap_table_size", 16384, 4294966272, false),
  2365  		Default:           int64(16777216),
  2366  	},
  2367  	"max_insert_delayed_threads": {
  2368  		Name:              "max_insert_delayed_threads",
  2369  		Scope:             ScopeBoth,
  2370  		Dynamic:           true,
  2371  		SetVarHintApplies: false,
  2372  		Type:              InitSystemVariableIntType("max_insert_delayed_threads", 0, 16384, false),
  2373  		Default:           int64(20),
  2374  	},
  2375  	"max_join_size": {
  2376  		Name:              "max_join_size",
  2377  		Scope:             ScopeBoth,
  2378  		Dynamic:           true,
  2379  		SetVarHintApplies: true,
  2380  		Type:              InitSystemVariableIntType("max_join_size", 0, math.MaxInt64, false),
  2381  		Default:           int64(math.MaxInt64),
  2382  	},
  2383  	"max_length_for_sort_data": {
  2384  		Name:              "max_length_for_sort_data",
  2385  		Scope:             ScopeBoth,
  2386  		Dynamic:           true,
  2387  		SetVarHintApplies: true,
  2388  		Type:              InitSystemVariableIntType("max_length_for_sort_data", 4, 8388608, false),
  2389  		Default:           int64(4096),
  2390  	},
  2391  	"max_points_in_geometry": {
  2392  		Name:              "max_points_in_geometry",
  2393  		Scope:             ScopeBoth,
  2394  		Dynamic:           true,
  2395  		SetVarHintApplies: true,
  2396  		Type:              InitSystemVariableIntType("max_points_in_geometry", 3, 1048576, false),
  2397  		Default:           int64(65536),
  2398  	},
  2399  	"max_prepared_stmt_count": {
  2400  		Name:              "max_prepared_stmt_count",
  2401  		Scope:             ScopeGlobal,
  2402  		Dynamic:           true,
  2403  		SetVarHintApplies: false,
  2404  		Type:              InitSystemVariableIntType("max_prepared_stmt_count", 0, 4194304, false),
  2405  		Default:           int64(16382),
  2406  	},
  2407  	"max_seeks_for_key": {
  2408  		Name:              "max_seeks_for_key",
  2409  		Scope:             ScopeBoth,
  2410  		Dynamic:           true,
  2411  		SetVarHintApplies: true,
  2412  		Type:              InitSystemVariableIntType("max_seeks_for_key", 1, 4294967295, false),
  2413  		Default:           int64(4294967295),
  2414  	},
  2415  	"max_sort_length": {
  2416  		Name:              "max_sort_length",
  2417  		Scope:             ScopeBoth,
  2418  		Dynamic:           true,
  2419  		SetVarHintApplies: true,
  2420  		Type:              InitSystemVariableIntType("max_sort_length", 4, 8388608, false),
  2421  		Default:           int64(1024),
  2422  	},
  2423  	"max_sp_recursion_depth": {
  2424  		Name:              "max_sp_recursion_depth",
  2425  		Scope:             ScopeBoth,
  2426  		Dynamic:           true,
  2427  		SetVarHintApplies: false,
  2428  		Type:              InitSystemVariableIntType("max_sp_recursion_depth", 0, 255, false),
  2429  		Default:           int64(0),
  2430  	},
  2431  	"max_user_connections": {
  2432  		Name:              "max_user_connections",
  2433  		Scope:             ScopeBoth,
  2434  		Dynamic:           true,
  2435  		SetVarHintApplies: false,
  2436  		Type:              InitSystemVariableIntType("max_user_connections", 0, 4294967295, false),
  2437  		Default:           int64(0),
  2438  	},
  2439  	"max_write_lock_count": {
  2440  		Name:              "max_write_lock_count",
  2441  		Scope:             ScopeGlobal,
  2442  		Dynamic:           true,
  2443  		SetVarHintApplies: false,
  2444  		Type:              InitSystemVariableIntType("max_write_lock_count", 1, 4294967295, false),
  2445  		Default:           int64(4294967295),
  2446  	},
  2447  	"mecab_rc_file": {
  2448  		Name:              "mecab_rc_file",
  2449  		Scope:             ScopeGlobal,
  2450  		Dynamic:           false,
  2451  		SetVarHintApplies: false,
  2452  		Type:              InitSystemVariableStringType("mecab_rc_file"),
  2453  		Default:           "",
  2454  	},
  2455  	"metadata_locks_cache_size": {
  2456  		Name:              "metadata_locks_cache_size",
  2457  		Scope:             ScopeGlobal,
  2458  		Dynamic:           false,
  2459  		SetVarHintApplies: false,
  2460  		Type:              InitSystemVariableIntType("metadata_locks_cache_size", 1, 1048576, false),
  2461  		Default:           int64(1024),
  2462  	},
  2463  	"metadata_locks_hash_instances": {
  2464  		Name:              "metadata_locks_hash_instances",
  2465  		Scope:             ScopeGlobal,
  2466  		Dynamic:           false,
  2467  		SetVarHintApplies: false,
  2468  		Type:              InitSystemVariableIntType("metadata_locks_hash_instances", 1, 1024, false),
  2469  		Default:           int64(8),
  2470  	},
  2471  	"min_examined_row_limit": {
  2472  		Name:              "min_examined_row_limit",
  2473  		Scope:             ScopeBoth,
  2474  		Dynamic:           true,
  2475  		SetVarHintApplies: false,
  2476  		Type:              InitSystemVariableIntType("min_examined_row_limit", 0, 4294967295, false),
  2477  		Default:           int64(0),
  2478  	},
  2479  	"myisam_data_pointer_size": {
  2480  		Name:              "myisam_data_pointer_size",
  2481  		Scope:             ScopeGlobal,
  2482  		Dynamic:           true,
  2483  		SetVarHintApplies: false,
  2484  		Type:              InitSystemVariableIntType("myisam_data_pointer_size", 2, 7, false),
  2485  		Default:           int64(6),
  2486  	},
  2487  	"myisam_max_sort_file_size": {
  2488  		Name:              "myisam_max_sort_file_size",
  2489  		Scope:             ScopeGlobal,
  2490  		Dynamic:           true,
  2491  		SetVarHintApplies: false,
  2492  		Type:              InitSystemVariableIntType("myisam_max_sort_file_size", 0, 2146435072, false),
  2493  		Default:           int64(2146435072),
  2494  	},
  2495  	"myisam_mmap_size": {
  2496  		Name:              "myisam_mmap_size",
  2497  		Scope:             ScopeGlobal,
  2498  		Dynamic:           false,
  2499  		SetVarHintApplies: false,
  2500  		Type:              InitSystemVariableIntType("myisam_mmap_size", 7, 4294967295, false),
  2501  		Default:           int64(4294967295),
  2502  	},
  2503  	"myisam_recover_options": {
  2504  		Name:              "myisam_recover_options",
  2505  		Scope:             ScopeGlobal,
  2506  		Dynamic:           false,
  2507  		SetVarHintApplies: false,
  2508  		Type:              InitSystemSystemEnumType("myisam_recover_options", "OFF", "DEFAULT", "BACKUP", "FORCE", "QUICK"),
  2509  		Default:           "OFF",
  2510  	},
  2511  	"myisam_repair_threads": {
  2512  		Name:              "myisam_repair_threads",
  2513  		Scope:             ScopeBoth,
  2514  		Dynamic:           true,
  2515  		SetVarHintApplies: false,
  2516  		Type:              InitSystemVariableIntType("myisam_repair_threads", 1, 4294967295, false),
  2517  		Default:           int64(1),
  2518  	},
  2519  	"myisam_sort_buffer_size": {
  2520  		Name:              "myisam_sort_buffer_size",
  2521  		Scope:             ScopeBoth,
  2522  		Dynamic:           true,
  2523  		SetVarHintApplies: false,
  2524  		Type:              InitSystemVariableIntType("myisam_sort_buffer_size", 4096, 4294967295, false),
  2525  		Default:           int64(8388608),
  2526  	},
  2527  	"myisam_stats_method": {
  2528  		Name:              "myisam_stats_method",
  2529  		Scope:             ScopeBoth,
  2530  		Dynamic:           true,
  2531  		SetVarHintApplies: false,
  2532  		Type:              InitSystemSystemEnumType("myisam_stats_method", "nulls_unequal", "nulls_equal", "nulls_ignored"),
  2533  		Default:           "nulls_unequal",
  2534  	},
  2535  	"myisam_use_mmap": {
  2536  		Name:              "myisam_use_mmap",
  2537  		Scope:             ScopeGlobal,
  2538  		Dynamic:           true,
  2539  		SetVarHintApplies: false,
  2540  		Type:              InitSystemVariableBoolType("myisam_use_mmap"),
  2541  		Default:           int64(0),
  2542  	},
  2543  	"mysql_native_password_proxy_users": {
  2544  		Name:              "mysql_native_password_proxy_users",
  2545  		Scope:             ScopeGlobal,
  2546  		Dynamic:           true,
  2547  		SetVarHintApplies: false,
  2548  		Type:              InitSystemVariableBoolType("mysql_native_password_proxy_users"),
  2549  		Default:           int64(0),
  2550  	},
  2551  	"named_pipe": {
  2552  		Name:              "named_pipe",
  2553  		Scope:             ScopeGlobal,
  2554  		Dynamic:           false,
  2555  		SetVarHintApplies: false,
  2556  		Type:              InitSystemVariableBoolType("named_pipe"),
  2557  		Default:           int64(0),
  2558  	},
  2559  	"named_pipe_full_access_group": {
  2560  		Name:              "named_pipe_full_access_group",
  2561  		Scope:             ScopeGlobal,
  2562  		Dynamic:           false,
  2563  		SetVarHintApplies: false,
  2564  		Type:              InitSystemVariableStringType("named_pipe_full_access_group"),
  2565  		Default:           "",
  2566  	},
  2567  	"net_read_timeout": {
  2568  		Name:              "net_read_timeout",
  2569  		Scope:             ScopeBoth,
  2570  		Dynamic:           true,
  2571  		SetVarHintApplies: false,
  2572  		Type:              InitSystemVariableIntType("net_read_timeout", 1, 31536000, false),
  2573  		Default:           int64(30),
  2574  	},
  2575  	"net_retry_count": {
  2576  		Name:              "net_retry_count",
  2577  		Scope:             ScopeBoth,
  2578  		Dynamic:           true,
  2579  		SetVarHintApplies: false,
  2580  		Type:              InitSystemVariableIntType("net_retry_count", 1, 4294967295, false),
  2581  		Default:           int64(10),
  2582  	},
  2583  	"new": {
  2584  		Name:              "new",
  2585  		Scope:             ScopeBoth,
  2586  		Dynamic:           true,
  2587  		SetVarHintApplies: false,
  2588  		Type:              InitSystemVariableBoolType("new"),
  2589  		Default:           int64(0),
  2590  	},
  2591  	"ngram_token_size": {
  2592  		Name:              "ngram_token_size",
  2593  		Scope:             ScopeGlobal,
  2594  		Dynamic:           false,
  2595  		SetVarHintApplies: false,
  2596  		Type:              InitSystemVariableIntType("ngram_token_size", 1, 10, false),
  2597  		Default:           int64(2),
  2598  	},
  2599  	"offline_mode": {
  2600  		Name:              "offline_mode",
  2601  		Scope:             ScopeGlobal,
  2602  		Dynamic:           true,
  2603  		SetVarHintApplies: false,
  2604  		Type:              InitSystemVariableBoolType("offline_mode"),
  2605  		Default:           int64(0),
  2606  	},
  2607  	"old": {
  2608  		Name:              "old",
  2609  		Scope:             ScopeGlobal,
  2610  		Dynamic:           true,
  2611  		SetVarHintApplies: false,
  2612  		Type:              InitSystemVariableBoolType("old"),
  2613  		Default:           int64(0),
  2614  	},
  2615  	"old_alter_table": {
  2616  		Name:              "old_alter_table",
  2617  		Scope:             ScopeBoth,
  2618  		Dynamic:           true,
  2619  		SetVarHintApplies: false,
  2620  		Type:              InitSystemVariableBoolType("old_alter_table"),
  2621  		Default:           int64(0),
  2622  	},
  2623  	"open_files_limit": {
  2624  		Name:              "open_files_limit",
  2625  		Scope:             ScopeGlobal,
  2626  		Dynamic:           true,
  2627  		SetVarHintApplies: false,
  2628  		Type:              InitSystemVariableIntType("open_files_limit", 0, 1048576, false),
  2629  		Default:           int64(5000),
  2630  	},
  2631  	"optimizer_hints": {
  2632  		Name:              "optimizer_hints",
  2633  		Scope:             ScopeBoth,
  2634  		Dynamic:           true,
  2635  		SetVarHintApplies: false,
  2636  		Type:              InitSystemVariableStringType("optimizer_hints"),
  2637  		Default:           "",
  2638  	},
  2639  	"optimizer_prune_level": {
  2640  		Name:              "optimizer_prune_level",
  2641  		Scope:             ScopeBoth,
  2642  		Dynamic:           true,
  2643  		SetVarHintApplies: false,
  2644  		Type:              InitSystemVariableIntType("optimizer_prune_level", 0, 1, false),
  2645  		Default:           int64(1),
  2646  	},
  2647  	"optimizer_search_depth": {
  2648  		Name:              "optimizer_search_depth",
  2649  		Scope:             ScopeBoth,
  2650  		Dynamic:           true,
  2651  		SetVarHintApplies: false,
  2652  		Type:              InitSystemVariableIntType("optimizer_search_depth", 0, 62, false),
  2653  		Default:           int64(62),
  2654  	},
  2655  	"optimizer_trace": {
  2656  		Name:              "optimizer_trace",
  2657  		Scope:             ScopeBoth,
  2658  		Dynamic:           true,
  2659  		SetVarHintApplies: false,
  2660  		Type:              InitSystemVariableStringType("optimizer_trace"),
  2661  		Default:           "",
  2662  	},
  2663  	"optimizer_trace_features": {
  2664  		Name:              "optimizer_trace_features",
  2665  		Scope:             ScopeBoth,
  2666  		Dynamic:           true,
  2667  		SetVarHintApplies: false,
  2668  		Type:              InitSystemVariableStringType("optimizer_trace_features"),
  2669  		Default:           "",
  2670  	},
  2671  	"optimizer_trace_limit": {
  2672  		Name:              "optimizer_trace_limit",
  2673  		Scope:             ScopeBoth,
  2674  		Dynamic:           true,
  2675  		SetVarHintApplies: false,
  2676  		Type:              InitSystemVariableIntType("optimizer_trace_limit", 0, 2147483647, false),
  2677  		Default:           int64(1),
  2678  	},
  2679  	"optimizer_trace_max_mem_size": {
  2680  		Name:              "optimizer_trace_max_mem_size",
  2681  		Scope:             ScopeBoth,
  2682  		Dynamic:           true,
  2683  		SetVarHintApplies: false,
  2684  		Type:              InitSystemVariableIntType("optimizer_trace_max_mem_size", 0, 4294967295, false),
  2685  		Default:           int64(1048576),
  2686  	},
  2687  	"optimizer_trace_offset": {
  2688  		Name:              "optimizer_trace_offset",
  2689  		Scope:             ScopeBoth,
  2690  		Dynamic:           true,
  2691  		SetVarHintApplies: false,
  2692  		Type:              InitSystemVariableIntType("optimizer_trace_offset", -2147483647, 2147483647, false),
  2693  		Default:           int64(-1),
  2694  	},
  2695  	"parser_max_mem_size": {
  2696  		Name:              "parser_max_mem_size",
  2697  		Scope:             ScopeBoth,
  2698  		Dynamic:           true,
  2699  		SetVarHintApplies: false,
  2700  		Type:              InitSystemVariableIntType("parser_max_mem_size", 10000000, 4294967295, false),
  2701  		Default:           int64(4294967295),
  2702  	},
  2703  	"partial_revokes": {
  2704  		Name:              "partial_revokes",
  2705  		Scope:             ScopeGlobal,
  2706  		Dynamic:           true,
  2707  		SetVarHintApplies: false,
  2708  		Type:              InitSystemVariableBoolType("partial_revokes"),
  2709  		Default:           int64(0),
  2710  	},
  2711  	"password_history": {
  2712  		Name:              "password_history",
  2713  		Scope:             ScopeGlobal,
  2714  		Dynamic:           true,
  2715  		SetVarHintApplies: false,
  2716  		Type:              InitSystemVariableIntType("password_history", 0, 4294967295, false),
  2717  		Default:           int64(0),
  2718  	},
  2719  	"password_require_current": {
  2720  		Name:              "password_require_current",
  2721  		Scope:             ScopeGlobal,
  2722  		Dynamic:           true,
  2723  		SetVarHintApplies: false,
  2724  		Type:              InitSystemVariableBoolType("password_require_current"),
  2725  		Default:           int64(0),
  2726  	},
  2727  	"password_reuse_interval": {
  2728  		Name:              "password_reuse_interval",
  2729  		Scope:             ScopeGlobal,
  2730  		Dynamic:           true,
  2731  		SetVarHintApplies: false,
  2732  		Type:              InitSystemVariableIntType("password_reuse_interval", 0, 4294967295, false),
  2733  		Default:           int64(0),
  2734  	},
  2735  	"persisted_globals_load": {
  2736  		Name:              "persisted_globals_load",
  2737  		Scope:             ScopeGlobal,
  2738  		Dynamic:           true,
  2739  		SetVarHintApplies: false,
  2740  		Type:              InitSystemVariableBoolType("persisted_globals_load"),
  2741  		Default:           int64(0),
  2742  	},
  2743  	"persist_only_admin_x509_subject": {
  2744  		Name:              "persist_only_admin_x509_subject",
  2745  		Scope:             ScopeGlobal,
  2746  		Dynamic:           true,
  2747  		SetVarHintApplies: false,
  2748  		Type:              InitSystemVariableStringType("persist_only_admin_x509_subject"),
  2749  		Default:           "",
  2750  	},
  2751  	"persist_sensitive_variables_in_plaintext": {
  2752  		Name:              "persist_sensitive_variables_in_plaintext",
  2753  		Scope:             ScopeGlobal,
  2754  		Dynamic:           false,
  2755  		SetVarHintApplies: false,
  2756  		Type:              InitSystemVariableBoolType("persist_sensitive_variables_in_plaintext"),
  2757  		Default:           int64(0),
  2758  	},
  2759  	"preload_buffer_size": {
  2760  		Name:              "preload_buffer_size",
  2761  		Scope:             ScopeBoth,
  2762  		Dynamic:           true,
  2763  		SetVarHintApplies: false,
  2764  		Type:              InitSystemVariableIntType("preload_buffer_size", 1024, 1073741824, false),
  2765  		Default:           int64(32768),
  2766  	},
  2767  	"print_identified_with_as_hex": {
  2768  		Name:              "print_identified_with_as_hex",
  2769  		Scope:             ScopeBoth,
  2770  		Dynamic:           true,
  2771  		SetVarHintApplies: false,
  2772  		Type:              InitSystemVariableBoolType("print_identified_with_as_hex"),
  2773  		Default:           int64(0),
  2774  	},
  2775  	"protocol_version": {
  2776  		Name:              "protocol_version",
  2777  		Scope:             ScopeGlobal,
  2778  		Dynamic:           false,
  2779  		SetVarHintApplies: false,
  2780  		Type:              InitSystemVariableIntType("protocol_version", 0, 4294967295, false),
  2781  		Default:           int64(10),
  2782  	},
  2783  	"proxy_user": {
  2784  		Name:              "proxy_user",
  2785  		Scope:             ScopeSession,
  2786  		Dynamic:           false,
  2787  		SetVarHintApplies: false,
  2788  		Type:              InitSystemVariableStringType("proxy_user"),
  2789  		Default:           "",
  2790  	},
  2791  	"pseudo_replica_mode": {
  2792  		Name:              "pseudo_replica_mode",
  2793  		Scope:             ScopeSession,
  2794  		Dynamic:           true,
  2795  		SetVarHintApplies: false,
  2796  		Type:              InitSystemVariableBoolType("pseudo_replica_mode"),
  2797  		Default:           int64(0),
  2798  	},
  2799  	"pseudo_slave_mode": {
  2800  		Name:              "pseudo_slave_mode",
  2801  		Scope:             ScopeSession,
  2802  		Dynamic:           true,
  2803  		SetVarHintApplies: false,
  2804  		Type:              InitSystemVariableBoolType("pseudo_slave_mode"),
  2805  		Default:           int64(0),
  2806  	},
  2807  	"pseudo_thread_id": {
  2808  		Name:              "pseudo_thread_id",
  2809  		Scope:             ScopeSession,
  2810  		Dynamic:           true,
  2811  		SetVarHintApplies: false,
  2812  		Type:              InitSystemVariableIntType("pseudo_thread_id", 0, 2147483647, false),
  2813  		Default:           int64(2147483647),
  2814  	},
  2815  	"query_alloc_block_size": {
  2816  		Name:              "query_alloc_block_size",
  2817  		Scope:             ScopeBoth,
  2818  		Dynamic:           true,
  2819  		SetVarHintApplies: false,
  2820  		Type:              InitSystemVariableIntType("pseudo_thread_id", 1024, 4294966272, false),
  2821  		Default:           int64(8192),
  2822  	},
  2823  	"rand_seed1": {
  2824  		Name:              "rand_seed1",
  2825  		Scope:             ScopeSession,
  2826  		Dynamic:           true,
  2827  		SetVarHintApplies: false,
  2828  		Type:              InitSystemVariableIntType("rand_seed1", 0, 4294967295, false),
  2829  		Default:           int64(0),
  2830  	},
  2831  	"rand_seed2": {
  2832  		Name:              "rand_seed2",
  2833  		Scope:             ScopeSession,
  2834  		Dynamic:           true,
  2835  		SetVarHintApplies: false,
  2836  		Type:              InitSystemVariableIntType("rand_seed2", 0, 4294967295, false),
  2837  		Default:           int64(0),
  2838  	},
  2839  	"range_optimizer_max_mem_size": {
  2840  		Name:              "range_optimizer_max_mem_size",
  2841  		Scope:             ScopeBoth,
  2842  		Dynamic:           true,
  2843  		SetVarHintApplies: false,
  2844  		Type:              InitSystemVariableIntType("range_optimizer_max_mem_size", 0, 4294967295, false),
  2845  		Default:           int64(8388608),
  2846  	},
  2847  	"rbr_exec_mode": {
  2848  		Name:              "rbr_exec_mode",
  2849  		Scope:             ScopeSession,
  2850  		Dynamic:           true,
  2851  		SetVarHintApplies: false,
  2852  		Type:              InitSystemSystemEnumType("rbr_exec_mode", "STRICT", "IDEMPOTENT"),
  2853  		Default:           "STRICT",
  2854  	},
  2855  	"read_buffer_size": {
  2856  		Name:              "read_buffer_size",
  2857  		Scope:             ScopeBoth,
  2858  		Dynamic:           true,
  2859  		SetVarHintApplies: false,
  2860  		Type:              InitSystemVariableIntType("read_buffer_size", 8192, 2147479552, false),
  2861  		Default:           int64(131072),
  2862  	},
  2863  	"read_only": {
  2864  		Name:              "read_only",
  2865  		Scope:             ScopeGlobal,
  2866  		Dynamic:           true,
  2867  		SetVarHintApplies: false,
  2868  		Type:              InitSystemVariableBoolType("read_only"),
  2869  		Default:           int64(0),
  2870  	},
  2871  	"read_rnd_buffer_size": {
  2872  		Name:              "read_rnd_buffer_size",
  2873  		Scope:             ScopeBoth,
  2874  		Dynamic:           true,
  2875  		SetVarHintApplies: false,
  2876  		Type:              InitSystemVariableIntType("read_rnd_buffer_size", 1, 2147483647, false),
  2877  		Default:           int64(262144),
  2878  	},
  2879  	"regexp_stack_limit": {
  2880  		Name:              "regexp_stack_limit",
  2881  		Scope:             ScopeGlobal,
  2882  		Dynamic:           true,
  2883  		SetVarHintApplies: false,
  2884  		Type:              InitSystemVariableIntType("regexp_stack_limit", 1, 2147483647, false),
  2885  		Default:           int64(8000000),
  2886  	},
  2887  	"regexp_time_limit": {
  2888  		Name:              "regexp_time_limit",
  2889  		Scope:             ScopeGlobal,
  2890  		Dynamic:           true,
  2891  		SetVarHintApplies: false,
  2892  		Type:              InitSystemVariableIntType("regexp_time_limit", 0, 2147483647, false),
  2893  		Default:           int64(32),
  2894  	},
  2895  	"require_row_format": {
  2896  		Name:              "require_row_format",
  2897  		Scope:             ScopeSession,
  2898  		Dynamic:           true,
  2899  		SetVarHintApplies: false,
  2900  		Type:              InitSystemVariableBoolType("require_row_format"),
  2901  		Default:           int64(0),
  2902  	},
  2903  	"require_secure_transport": {
  2904  		Name:              "require_secure_transport",
  2905  		Scope:             ScopeGlobal,
  2906  		Dynamic:           true,
  2907  		SetVarHintApplies: false,
  2908  		Type:              InitSystemVariableBoolType("require_secure_transport"),
  2909  		Default:           int64(0),
  2910  	},
  2911  	"resultset_metadata": {
  2912  		Name:              "resultset_metadata",
  2913  		Scope:             ScopeSession,
  2914  		Dynamic:           true,
  2915  		SetVarHintApplies: false,
  2916  		Type:              InitSystemSystemEnumType("resultset_metadata", "FULL", "NONE"),
  2917  		Default:           "FULL",
  2918  	},
  2919  	"runtime_filter_limit_in": {
  2920  		Name:              "runtime_filter_limit_in",
  2921  		Scope:             ScopeBoth,
  2922  		Dynamic:           true,
  2923  		SetVarHintApplies: false,
  2924  		Type:              InitSystemVariableIntType("runtime_filter_limit_in", 1, 4294967295, false),
  2925  		Default:           int64(10000),
  2926  	},
  2927  	"runtime_filter_limit_bloom_filter": {
  2928  		Name:              "runtime_filter_limit_bloom_filter",
  2929  		Scope:             ScopeBoth,
  2930  		Dynamic:           true,
  2931  		SetVarHintApplies: false,
  2932  		Type:              InitSystemVariableIntType("runtime_filter_limit_bloom_filter", 1, 4294967295, false),
  2933  		Default:           int64(1000000),
  2934  	},
  2935  	"schema_definition_cache": {
  2936  		Name:              "schema_definition_cache",
  2937  		Scope:             ScopeGlobal,
  2938  		Dynamic:           true,
  2939  		SetVarHintApplies: false,
  2940  		Type:              InitSystemVariableIntType("schema_definition_cache", 256, 524288, false),
  2941  		Default:           int64(256),
  2942  	},
  2943  	"secure_file_priv": {
  2944  		Name:              "secure_file_priv",
  2945  		Scope:             ScopeGlobal,
  2946  		Dynamic:           false,
  2947  		SetVarHintApplies: false,
  2948  		Type:              InitSystemVariableStringType("secure_file_priv"),
  2949  		Default:           "",
  2950  	},
  2951  	"select_into_disk_sync": {
  2952  		Name:              "select_into_disk_sync",
  2953  		Scope:             ScopeBoth,
  2954  		Dynamic:           true,
  2955  		SetVarHintApplies: false,
  2956  		Type:              InitSystemVariableBoolType("select_into_disk_sync"),
  2957  		Default:           int64(0),
  2958  	},
  2959  	"select_into_disk_sync_delay": {
  2960  		Name:              "select_into_disk_sync_delay",
  2961  		Scope:             ScopeBoth,
  2962  		Dynamic:           true,
  2963  		SetVarHintApplies: false,
  2964  		Type:              InitSystemVariableIntType("select_into_disk_sync_delay", 0, 31536000, false),
  2965  		Default:           int64(0),
  2966  	},
  2967  	"session_track_gtids": {
  2968  		Name:              "session_track_gtids",
  2969  		Scope:             ScopeSession,
  2970  		Dynamic:           true,
  2971  		SetVarHintApplies: false,
  2972  		Type:              InitSystemSystemEnumType("session_track_gtids", "OFF", "OWN_GTID", "ALL_GTIDS"),
  2973  		Default:           "OFF",
  2974  	},
  2975  	"session_track_schema": {
  2976  		Name:              "session_track_schema",
  2977  		Scope:             ScopeBoth,
  2978  		Dynamic:           true,
  2979  		SetVarHintApplies: false,
  2980  		Type:              InitSystemVariableBoolType("session_track_schema"),
  2981  		Default:           int64(1),
  2982  	},
  2983  	"session_track_state_change": {
  2984  		Name:              "session_track_state_change",
  2985  		Scope:             ScopeBoth,
  2986  		Dynamic:           true,
  2987  		SetVarHintApplies: false,
  2988  		Type:              InitSystemVariableBoolType("session_track_state_change"),
  2989  		Default:           int64(0),
  2990  	},
  2991  	"session_track_system_variables": {
  2992  		Name:              "session_track_system_variables",
  2993  		Scope:             ScopeGlobal,
  2994  		Dynamic:           false,
  2995  		SetVarHintApplies: false,
  2996  		Type:              InitSystemVariableStringType("session_track_system_variables"),
  2997  		Default:           "time_zone, autocommit, character_set_client, character_set_results, character_set_connection",
  2998  	},
  2999  	"session_track_transaction_info": {
  3000  		Name:              "session_track_transaction_info",
  3001  		Scope:             ScopeSession,
  3002  		Dynamic:           true,
  3003  		SetVarHintApplies: false,
  3004  		Type:              InitSystemSystemEnumType("session_track_transaction_info", "OFF", "STATE", "CHARACTERISTICS"),
  3005  		Default:           "OFF",
  3006  	},
  3007  	"sha256_password_auto_generate_rsa_keys": {
  3008  		Name:              "sha256_password_auto_generate_rsa_keys",
  3009  		Scope:             ScopeGlobal,
  3010  		Dynamic:           true,
  3011  		SetVarHintApplies: false,
  3012  		Type:              InitSystemVariableBoolType("sha256_password_auto_generate_rsa_keys"),
  3013  		Default:           int64(1),
  3014  	},
  3015  	"sha256_password_proxy_users": {
  3016  		Name:              "sha256_password_proxy_users",
  3017  		Scope:             ScopeGlobal,
  3018  		Dynamic:           true,
  3019  		SetVarHintApplies: false,
  3020  		Type:              InitSystemVariableBoolType("sha256_password_proxy_users"),
  3021  		Default:           int64(0),
  3022  	},
  3023  	"shared_memory": {
  3024  		Name:              "shared_memory",
  3025  		Scope:             ScopeGlobal,
  3026  		Dynamic:           true,
  3027  		SetVarHintApplies: false,
  3028  		Type:              InitSystemVariableBoolType("shared_memory"),
  3029  		Default:           int64(0),
  3030  	},
  3031  	"shared_memory_base_name": {
  3032  		Name:              "shared_memory_base_name",
  3033  		Scope:             ScopeGlobal,
  3034  		Dynamic:           false,
  3035  		SetVarHintApplies: false,
  3036  		Type:              InitSystemVariableStringType("session_track_system_variables"),
  3037  		Default:           "MYSQL",
  3038  	},
  3039  	"show_create_table_skip_secondary_engine": {
  3040  		Name:              "show_create_table_skip_secondary_engine",
  3041  		Scope:             ScopeSession,
  3042  		Dynamic:           true,
  3043  		SetVarHintApplies: false,
  3044  		Type:              InitSystemVariableBoolType("show_create_table_skip_secondary_engine"),
  3045  		Default:           int64(0),
  3046  	},
  3047  	"show_create_table_verbosity": {
  3048  		Name:              "show_create_table_verbosity",
  3049  		Scope:             ScopeBoth,
  3050  		Dynamic:           true,
  3051  		SetVarHintApplies: false,
  3052  		Type:              InitSystemVariableBoolType("show_create_table_verbosity"),
  3053  		Default:           int64(0),
  3054  	},
  3055  	"show_gipk_in_create_table_and_information_schema": {
  3056  		Name:              "show_gipk_in_create_table_and_information_schema",
  3057  		Scope:             ScopeBoth,
  3058  		Dynamic:           true,
  3059  		SetVarHintApplies: false,
  3060  		Type:              InitSystemVariableBoolType("show_gipk_in_create_table_and_information_schema"),
  3061  		Default:           int64(1),
  3062  	},
  3063  	"show_old_temporals": {
  3064  		Name:              "show_old_temporals",
  3065  		Scope:             ScopeBoth,
  3066  		Dynamic:           true,
  3067  		SetVarHintApplies: false,
  3068  		Type:              InitSystemVariableBoolType("show_old_temporals"),
  3069  		Default:           int64(0),
  3070  	},
  3071  	"skip_external_locking": {
  3072  		Name:              "skip_external_locking",
  3073  		Scope:             ScopeBoth,
  3074  		Dynamic:           true,
  3075  		SetVarHintApplies: false,
  3076  		Type:              InitSystemVariableBoolType("skip_external_locking"),
  3077  		Default:           int64(1),
  3078  	},
  3079  	"skip_name_resolve": {
  3080  		Name:              "skip_name_resolve",
  3081  		Scope:             ScopeBoth,
  3082  		Dynamic:           true,
  3083  		SetVarHintApplies: false,
  3084  		Type:              InitSystemVariableBoolType("skip_name_resolve"),
  3085  		Default:           int64(0),
  3086  	},
  3087  	"skip_networking": {
  3088  		Name:              "skip_networking",
  3089  		Scope:             ScopeBoth,
  3090  		Dynamic:           true,
  3091  		SetVarHintApplies: false,
  3092  		Type:              InitSystemVariableBoolType("skip_networking"),
  3093  		Default:           int64(0),
  3094  	},
  3095  	"skip_show_database": {
  3096  		Name:              "skip_show_database",
  3097  		Scope:             ScopeBoth,
  3098  		Dynamic:           true,
  3099  		SetVarHintApplies: false,
  3100  		Type:              InitSystemVariableBoolType("skip_show_database"),
  3101  		Default:           int64(0),
  3102  	},
  3103  	"slow_query_log": {
  3104  		Name:              "slow_query_log",
  3105  		Scope:             ScopeBoth,
  3106  		Dynamic:           true,
  3107  		SetVarHintApplies: false,
  3108  		Type:              InitSystemVariableBoolType("slow_query_log"),
  3109  		Default:           int64(0),
  3110  	},
  3111  	"slow_launch_time": {
  3112  		Name:              "slow_launch_time",
  3113  		Scope:             ScopeGlobal,
  3114  		Dynamic:           true,
  3115  		SetVarHintApplies: false,
  3116  		Type:              InitSystemVariableIntType("slow_launch_time", 0, 31536000, false),
  3117  		Default:           int64(2),
  3118  	},
  3119  	"socket": {
  3120  		Name:              "socket",
  3121  		Scope:             ScopeGlobal,
  3122  		Dynamic:           false,
  3123  		SetVarHintApplies: false,
  3124  		Type:              InitSystemVariableStringType("socket"),
  3125  		Default:           "/tmp/mysql.sock",
  3126  	},
  3127  	"sql_auto_is_null": {
  3128  		Name:              "sql_auto_is_null",
  3129  		Scope:             ScopeBoth,
  3130  		Dynamic:           true,
  3131  		SetVarHintApplies: false,
  3132  		Type:              InitSystemVariableBoolType("sql_auto_is_null"),
  3133  		Default:           int64(1),
  3134  	},
  3135  	"sql_big_selects": {
  3136  		Name:              "sql_big_selects",
  3137  		Scope:             ScopeBoth,
  3138  		Dynamic:           true,
  3139  		SetVarHintApplies: false,
  3140  		Type:              InitSystemVariableBoolType("sql_big_selects"),
  3141  		Default:           int64(0),
  3142  	},
  3143  	"sql_buffer_result": {
  3144  		Name:              "sql_buffer_result",
  3145  		Scope:             ScopeBoth,
  3146  		Dynamic:           true,
  3147  		SetVarHintApplies: false,
  3148  		Type:              InitSystemVariableBoolType("sql_buffer_result"),
  3149  		Default:           int64(0),
  3150  	},
  3151  	"sql_generate_invisible_primary_key": {
  3152  		Name:              "sql_generate_invisible_primary_key",
  3153  		Scope:             ScopeBoth,
  3154  		Dynamic:           true,
  3155  		SetVarHintApplies: false,
  3156  		Type:              InitSystemVariableBoolType("sql_generate_invisible_primary_key"),
  3157  		Default:           int64(0),
  3158  	},
  3159  	"sql_log_off": {
  3160  		Name:              "sql_log_off",
  3161  		Scope:             ScopeBoth,
  3162  		Dynamic:           true,
  3163  		SetVarHintApplies: false,
  3164  		Type:              InitSystemVariableBoolType("sql_log_off"),
  3165  		Default:           int64(0),
  3166  	},
  3167  	"sql_log_bin": {
  3168  		Name:              "sql_log_bin",
  3169  		Scope:             ScopeBoth,
  3170  		Dynamic:           true,
  3171  		SetVarHintApplies: false,
  3172  		Type:              InitSystemVariableBoolType("sql_log_bin"),
  3173  		Default:           int64(0),
  3174  	},
  3175  	"sql_notes": {
  3176  		Name:              "sql_notes",
  3177  		Scope:             ScopeBoth,
  3178  		Dynamic:           true,
  3179  		SetVarHintApplies: false,
  3180  		Type:              InitSystemVariableBoolType("sql_notes"),
  3181  		Default:           int64(1),
  3182  	},
  3183  	"sql_quote_show_create": {
  3184  		Name:              "sql_quote_show_create",
  3185  		Scope:             ScopeBoth,
  3186  		Dynamic:           true,
  3187  		SetVarHintApplies: false,
  3188  		Type:              InitSystemVariableBoolType("sql_quote_show_create"),
  3189  		Default:           int64(1),
  3190  	},
  3191  	"sql_require_primary_key": {
  3192  		Name:              "sql_require_primary_key",
  3193  		Scope:             ScopeBoth,
  3194  		Dynamic:           true,
  3195  		SetVarHintApplies: false,
  3196  		Type:              InitSystemVariableBoolType("sql_require_primary_key"),
  3197  		Default:           int64(0),
  3198  	},
  3199  	"sql_warnings": {
  3200  		Name:              "sql_warnings",
  3201  		Scope:             ScopeBoth,
  3202  		Dynamic:           true,
  3203  		SetVarHintApplies: false,
  3204  		Type:              InitSystemVariableBoolType("sql_warnings"),
  3205  		Default:           int64(0),
  3206  	},
  3207  	"ssl_cipher": {
  3208  		Name:              "ssl_cipher",
  3209  		Scope:             ScopeGlobal,
  3210  		Dynamic:           false,
  3211  		SetVarHintApplies: false,
  3212  		Type:              InitSystemVariableStringType("ssl_cipher"),
  3213  		Default:           "",
  3214  	},
  3215  	"ssl_session_cache_mode": {
  3216  		Name:              "ssl_session_cache_mode",
  3217  		Scope:             ScopeGlobal,
  3218  		Dynamic:           true,
  3219  		SetVarHintApplies: false,
  3220  		Type:              InitSystemVariableBoolType("ssl_session_cache_mode"),
  3221  		Default:           int64(1),
  3222  	},
  3223  	"ssl_session_cache_timeout": {
  3224  		Name:              "ssl_session_cache_timeout",
  3225  		Scope:             ScopeGlobal,
  3226  		Dynamic:           true,
  3227  		SetVarHintApplies: false,
  3228  		Type:              InitSystemVariableIntType("ssl_session_cache_timeout", 0, 84600, false),
  3229  		Default:           int64(300),
  3230  	},
  3231  	"stored_program_cache": {
  3232  		Name:              "stored_program_cache",
  3233  		Scope:             ScopeGlobal,
  3234  		Dynamic:           true,
  3235  		SetVarHintApplies: false,
  3236  		Type:              InitSystemVariableIntType("stored_program_cache", 16, 524288, false),
  3237  		Default:           int64(256),
  3238  	},
  3239  	"stored_program_definition_cache": {
  3240  		Name:              "stored_program_definition_cache",
  3241  		Scope:             ScopeGlobal,
  3242  		Dynamic:           true,
  3243  		SetVarHintApplies: false,
  3244  		Type:              InitSystemVariableIntType("stored_program_definition_cache", 256, 524288, false),
  3245  		Default:           int64(256),
  3246  	},
  3247  	"super_read_only": {
  3248  		Name:              "super_read_only",
  3249  		Scope:             ScopeGlobal,
  3250  		Dynamic:           true,
  3251  		SetVarHintApplies: false,
  3252  		Type:              InitSystemVariableBoolType("super_read_only"),
  3253  		Default:           int64(0),
  3254  	},
  3255  	"table_definition_cache": {
  3256  		Name:              "table_definition_cache",
  3257  		Scope:             ScopeGlobal,
  3258  		Dynamic:           true,
  3259  		SetVarHintApplies: false,
  3260  		Type:              InitSystemVariableIntType("table_definition_cache", 400, 524288, false),
  3261  		Default:           int64(500),
  3262  	},
  3263  	"table_encryption_privilege_check": {
  3264  		Name:              "table_encryption_privilege_check",
  3265  		Scope:             ScopeGlobal,
  3266  		Dynamic:           true,
  3267  		SetVarHintApplies: false,
  3268  		Type:              InitSystemVariableBoolType("table_encryption_privilege_check"),
  3269  		Default:           int64(0),
  3270  	},
  3271  	"table_open_cache": {
  3272  		Name:              "table_open_cache",
  3273  		Scope:             ScopeGlobal,
  3274  		Dynamic:           true,
  3275  		SetVarHintApplies: false,
  3276  		Type:              InitSystemVariableIntType("table_definition_cache", 1, 524288, false),
  3277  		Default:           int64(4000),
  3278  	},
  3279  	"table_open_cache_instances": {
  3280  		Name:              "table_open_cache_instances",
  3281  		Scope:             ScopeGlobal,
  3282  		Dynamic:           false,
  3283  		SetVarHintApplies: false,
  3284  		Type:              InitSystemVariableIntType("table_open_cache_instances", 1, 64, false),
  3285  		Default:           int64(16),
  3286  	},
  3287  	"tablespace_definition_cache": {
  3288  		Name:              "tablespace_definition_cache",
  3289  		Scope:             ScopeGlobal,
  3290  		Dynamic:           true,
  3291  		SetVarHintApplies: false,
  3292  		Type:              InitSystemVariableIntType("tablespace_definition_cache", 256, 524288, false),
  3293  		Default:           int64(256),
  3294  	},
  3295  	"temptable_max_mmap": {
  3296  		Name:              "temptable_max_mmap",
  3297  		Scope:             ScopeGlobal,
  3298  		Dynamic:           true,
  3299  		SetVarHintApplies: false,
  3300  		Type:              InitSystemVariableIntType("temptable_max_mmap", 256, 4294967295, false),
  3301  		Default:           int64(1073741824),
  3302  	},
  3303  	"temptable_max_ram": {
  3304  		Name:              "temptable_max_ram",
  3305  		Scope:             ScopeGlobal,
  3306  		Dynamic:           true,
  3307  		SetVarHintApplies: false,
  3308  		Type:              InitSystemVariableIntType("temptable_max_ram", 2097152, 4294967295, false),
  3309  		Default:           int64(1073741824),
  3310  	},
  3311  	"temptable_use_mmap": {
  3312  		Name:              "temptable_use_mmap",
  3313  		Scope:             ScopeGlobal,
  3314  		Dynamic:           true,
  3315  		SetVarHintApplies: false,
  3316  		Type:              InitSystemVariableBoolType("temptable_use_mmap"),
  3317  		Default:           int64(1),
  3318  	},
  3319  	"thread_cache_size": {
  3320  		Name:              "thread_cache_size",
  3321  		Scope:             ScopeGlobal,
  3322  		Dynamic:           true,
  3323  		SetVarHintApplies: false,
  3324  		Type:              InitSystemVariableIntType("thread_cache_size", 0, 16384, false),
  3325  		Default:           int64(1),
  3326  	},
  3327  	"thread_handling": {
  3328  		Name:              "thread_handling",
  3329  		Scope:             ScopeGlobal,
  3330  		Dynamic:           false,
  3331  		SetVarHintApplies: false,
  3332  		Type:              InitSystemSystemEnumType("thread_handling", "no-threads", "one-thread-per-connection", "loaded-dynamically"),
  3333  		Default:           "one-thread-per-connection",
  3334  	},
  3335  	"thread_pool_algorithm": {
  3336  		Name:              "thread_pool_algorithm",
  3337  		Scope:             ScopeGlobal,
  3338  		Dynamic:           true,
  3339  		SetVarHintApplies: false,
  3340  		Type:              InitSystemVariableIntType("thread_pool_algorithm", 0, 1, false),
  3341  		Default:           int64(0),
  3342  	},
  3343  	"thread_pool_dedicated_listeners": {
  3344  		Name:              "thread_pool_dedicated_listeners",
  3345  		Scope:             ScopeGlobal,
  3346  		Dynamic:           true,
  3347  		SetVarHintApplies: false,
  3348  		Type:              InitSystemVariableBoolType("thread_pool_dedicated_listeners"),
  3349  		Default:           int64(0),
  3350  	},
  3351  	"thread_pool_high_priority_connection": {
  3352  		Name:              "thread_pool_high_priority_connection",
  3353  		Scope:             ScopeGlobal,
  3354  		Dynamic:           true,
  3355  		SetVarHintApplies: false,
  3356  		Type:              InitSystemVariableIntType("thread_pool_high_priority_connection", 0, 1, false),
  3357  		Default:           int64(0),
  3358  	},
  3359  	"thread_pool_max_active_query_threads": {
  3360  		Name:              "thread_pool_max_active_query_threads",
  3361  		Scope:             ScopeGlobal,
  3362  		Dynamic:           true,
  3363  		SetVarHintApplies: false,
  3364  		Type:              InitSystemVariableIntType("thread_pool_max_active_query_threads", 0, 512, false),
  3365  		Default:           int64(0),
  3366  	},
  3367  	"thread_pool_max_transactions_limit": {
  3368  		Name:              "thread_pool_max_transactions_limit",
  3369  		Scope:             ScopeGlobal,
  3370  		Dynamic:           true,
  3371  		SetVarHintApplies: false,
  3372  		Type:              InitSystemVariableIntType("thread_pool_max_transactions_limit", 0, 1000000, false),
  3373  		Default:           int64(0),
  3374  	},
  3375  	"thread_pool_max_unused_threads": {
  3376  		Name:              "thread_pool_max_unused_threads",
  3377  		Scope:             ScopeGlobal,
  3378  		Dynamic:           true,
  3379  		SetVarHintApplies: false,
  3380  		Type:              InitSystemVariableIntType("thread_pool_max_unused_threads", 0, 4096, false),
  3381  		Default:           int64(0),
  3382  	},
  3383  	"thread_pool_prio_kickup_timer": {
  3384  		Name:              "thread_pool_prio_kickup_timer",
  3385  		Scope:             ScopeGlobal,
  3386  		Dynamic:           true,
  3387  		SetVarHintApplies: false,
  3388  		Type:              InitSystemVariableIntType("thread_pool_prio_kickup_timer", 0, 4294967294, false),
  3389  		Default:           int64(1000),
  3390  	},
  3391  	"thread_pool_query_threads_per_group": {
  3392  		Name:              "thread_pool_query_threads_per_group",
  3393  		Scope:             ScopeGlobal,
  3394  		Dynamic:           true,
  3395  		SetVarHintApplies: false,
  3396  		Type:              InitSystemVariableIntType("thread_pool_query_threads_per_group", 1, 4096, false),
  3397  		Default:           int64(1),
  3398  	},
  3399  	"thread_pool_size": {
  3400  		Name:              "thread_pool_size",
  3401  		Scope:             ScopeGlobal,
  3402  		Dynamic:           false,
  3403  		SetVarHintApplies: false,
  3404  		Type:              InitSystemVariableIntType("thread_pool_size", 1, 512, false),
  3405  		Default:           int64(1),
  3406  	},
  3407  	"thread_pool_stall_limit": {
  3408  		Name:              "thread_pool_stall_limit",
  3409  		Scope:             ScopeGlobal,
  3410  		Dynamic:           true,
  3411  		SetVarHintApplies: false,
  3412  		Type:              InitSystemVariableIntType("thread_pool_stall_limit", 4, 600, false),
  3413  		Default:           int64(6),
  3414  	},
  3415  	"thread_pool_transaction_delay": {
  3416  		Name:              "thread_pool_transaction_delay",
  3417  		Scope:             ScopeGlobal,
  3418  		Dynamic:           true,
  3419  		SetVarHintApplies: false,
  3420  		Type:              InitSystemVariableIntType("thread_pool_transaction_delay", 0, 300000, false),
  3421  		Default:           int64(0),
  3422  	},
  3423  	"transferred": {
  3424  		Name:              "transferred",
  3425  		Scope:             ScopeSession,
  3426  		Dynamic:           true,
  3427  		SetVarHintApplies: false,
  3428  		Type:              InitSystemVariableBoolType("autocommit"),
  3429  		Default:           int64(0),
  3430  	},
  3431  	"tls_ciphersuites": {
  3432  		Name:              "tls_ciphersuites",
  3433  		Scope:             ScopeGlobal,
  3434  		Dynamic:           true,
  3435  		SetVarHintApplies: false,
  3436  		Type:              InitSystemVariableStringType("tls_ciphersuites"),
  3437  		Default:           "",
  3438  	},
  3439  	"tls_version": {
  3440  		Name:              "tls_version",
  3441  		Scope:             ScopeGlobal,
  3442  		Dynamic:           false,
  3443  		SetVarHintApplies: false,
  3444  		Type:              InitSystemVariableStringType("tls_version"),
  3445  		Default:           "TLSv1.2,TLSv1.3",
  3446  	},
  3447  	"tmp_table_size": {
  3448  		Name:              "tmp_table_size",
  3449  		Scope:             ScopeBoth,
  3450  		Dynamic:           true,
  3451  		SetVarHintApplies: false,
  3452  		Type:              InitSystemVariableIntType("tmp_table_size", 1024, 4294967294, false),
  3453  		Default:           int64(16777216),
  3454  	},
  3455  	"transaction_alloc_block_size": {
  3456  		Name:              "transaction_alloc_block_size",
  3457  		Scope:             ScopeBoth,
  3458  		Dynamic:           true,
  3459  		SetVarHintApplies: false,
  3460  		Type:              InitSystemVariableIntType("transaction_alloc_block_size", 1024, 131072, false),
  3461  		Default:           int64(8192),
  3462  	},
  3463  	"transaction_prealloc_size": {
  3464  		Name:              "transaction_prealloc_size",
  3465  		Scope:             ScopeBoth,
  3466  		Dynamic:           true,
  3467  		SetVarHintApplies: false,
  3468  		Type:              InitSystemVariableIntType("transaction_prealloc_size", 1024, 131072, false),
  3469  		Default:           int64(4096),
  3470  	},
  3471  	"unique_checks": {
  3472  		Name:              "unique_checks",
  3473  		Scope:             ScopeBoth,
  3474  		Dynamic:           true,
  3475  		SetVarHintApplies: false,
  3476  		Type:              InitSystemVariableBoolType("unique_checks"),
  3477  		Default:           int64(1),
  3478  	},
  3479  	"updatable_views_with_limit": {
  3480  		Name:              "updatable_views_with_limit",
  3481  		Scope:             ScopeBoth,
  3482  		Dynamic:           true,
  3483  		SetVarHintApplies: false,
  3484  		Type:              InitSystemVariableBoolType("updatable_views_with_limit"),
  3485  		Default:           int64(1),
  3486  	},
  3487  	"use_secondary_engine": {
  3488  		Name:              "use_secondary_engine",
  3489  		Scope:             ScopeGlobal,
  3490  		Dynamic:           false,
  3491  		SetVarHintApplies: false,
  3492  		Type:              InitSystemSystemEnumType("use_secondary_engine", "OFF", "ON", "FORCED"),
  3493  		Default:           "ON",
  3494  	},
  3495  	"version_compile_machine": {
  3496  		Name:              "version_compile_machine",
  3497  		Scope:             ScopeGlobal,
  3498  		Dynamic:           false,
  3499  		SetVarHintApplies: false,
  3500  		Type:              InitSystemVariableStringType("version_compile_machine"),
  3501  		Default:           "",
  3502  	},
  3503  	"version_compile_os": {
  3504  		Name:              "version_compile_os",
  3505  		Scope:             ScopeGlobal,
  3506  		Dynamic:           false,
  3507  		SetVarHintApplies: false,
  3508  		Type:              InitSystemVariableStringType("version_compile_os"),
  3509  		Default:           "",
  3510  	},
  3511  	"version_compile_zlib": {
  3512  		Name:              "version_compile_zlib",
  3513  		Scope:             ScopeGlobal,
  3514  		Dynamic:           false,
  3515  		SetVarHintApplies: false,
  3516  		Type:              InitSystemVariableStringType("version_compile_zlib"),
  3517  		Default:           "",
  3518  	},
  3519  	"windowing_use_high_precision": {
  3520  		Name:              "windowing_use_high_precision",
  3521  		Scope:             ScopeBoth,
  3522  		Dynamic:           true,
  3523  		SetVarHintApplies: false,
  3524  		Type:              InitSystemVariableBoolType("windowing_use_high_precision"),
  3525  		Default:           int64(1),
  3526  	},
  3527  	"xa_detach_on_prepare": {
  3528  		Name:              "xa_detach_on_prepare",
  3529  		Scope:             ScopeBoth,
  3530  		Dynamic:           true,
  3531  		SetVarHintApplies: false,
  3532  		Type:              InitSystemVariableBoolType("xa_detach_on_prepare"),
  3533  		Default:           int64(1),
  3534  	},
  3535  	"version": {
  3536  		Name:              "version",
  3537  		Scope:             ScopeGlobal,
  3538  		Dynamic:           false,
  3539  		SetVarHintApplies: false,
  3540  		Type:              InitSystemVariableStringType("version"),
  3541  		Default:           "8.0.30-MatrixOne-v1.0.0",
  3542  	},
  3543  	"gtid_purged": {
  3544  		Name:              "gtid_purged",
  3545  		Scope:             ScopeGlobal,
  3546  		Dynamic:           true,
  3547  		SetVarHintApplies: false,
  3548  		Type:              InitSystemVariableStringType("gtid_purged"),
  3549  		Default:           "",
  3550  	},
  3551  	"transaction_operator_open_log": {
  3552  		Name:              "transaction_operator_open_log",
  3553  		Scope:             ScopeSession,
  3554  		Dynamic:           true,
  3555  		SetVarHintApplies: false,
  3556  		Type:              InitSystemVariableBoolType("transaction_operator_open_log"),
  3557  		Default:           int64(0),
  3558  	},
  3559  	"disable_txn_trace": {
  3560  		Name:              "disable_txn_trace",
  3561  		Scope:             ScopeSession,
  3562  		Dynamic:           true,
  3563  		SetVarHintApplies: false,
  3564  		Type:              InitSystemVariableBoolType("disable_txn_trace"),
  3565  		Default:           int64(0),
  3566  	},
  3567  	"keep_user_target_list_in_result": {
  3568  		Name:              "keep_user_target_list_in_result",
  3569  		Scope:             ScopeGlobal,
  3570  		Dynamic:           true,
  3571  		SetVarHintApplies: false,
  3572  		Type:              InitSystemVariableIntType("keep_user_target_list_in_result", 0, 2, false),
  3573  		Default:           int64(0),
  3574  	},
  3575  	"experimental_ivf_index": {
  3576  		Name:              "experimental_ivf_index",
  3577  		Scope:             ScopeGlobal,
  3578  		Dynamic:           true,
  3579  		SetVarHintApplies: false,
  3580  		Type:              InitSystemVariableBoolType("experimental_ivf_index"),
  3581  		Default:           int64(0),
  3582  	},
  3583  	"experimental_master_index": {
  3584  		Name:              "experimental_master_index",
  3585  		Scope:             ScopeGlobal,
  3586  		Dynamic:           true,
  3587  		SetVarHintApplies: false,
  3588  		Type:              InitSystemVariableBoolType("experimental_master_index"),
  3589  		Default:           int64(0),
  3590  	},
  3591  }
  3592  
  3593  func updateTimeZone(ctx context.Context, sess *Session, vars map[string]interface{}, name string, val interface{}) error {
  3594  	tzStr := val.(string)
  3595  	tzStr = strings.TrimSpace(strings.ToLower(tzStr))
  3596  	if tzStr == "system" {
  3597  		vars[name] = "SYSTEM"
  3598  		sess.SetTimeZone(time.Local)
  3599  	} else if len(tzStr) > 0 && (tzStr[0] == '-' || tzStr[0] == '+') {
  3600  		if len(tzStr) != 5 && len(tzStr) != 6 {
  3601  			return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3602  		}
  3603  
  3604  		minIdx := 3
  3605  		if tzStr[1] < '0' || tzStr[1] > '9' {
  3606  			return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3607  		}
  3608  		hour := int(tzStr[1] - '0')
  3609  		if tzStr[2] != ':' {
  3610  			if tzStr[2] < '0' || tzStr[2] > '9' {
  3611  				return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3612  			}
  3613  			hour = hour*10 + int(tzStr[2]-'0')
  3614  			minIdx = 4
  3615  			if tzStr[3] != ':' {
  3616  				return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3617  			}
  3618  		}
  3619  
  3620  		if minIdx != len(tzStr)-2 {
  3621  			return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3622  		}
  3623  		if tzStr[minIdx] < '0' || tzStr[minIdx] > '9' {
  3624  			return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3625  		}
  3626  		minute := int(tzStr[minIdx]-'0') * 10
  3627  		if tzStr[minIdx+1] < '0' || tzStr[minIdx+1] > '9' {
  3628  			return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3629  		}
  3630  		minute += int(tzStr[minIdx+1] - '0')
  3631  		if minute >= 60 {
  3632  			return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3633  		}
  3634  
  3635  		minute += hour * 60
  3636  
  3637  		if tzStr[0] == '-' {
  3638  			if minute >= 14*60 {
  3639  				return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3640  			}
  3641  			sess.SetTimeZone(time.FixedZone("FixedZone", -minute*60))
  3642  		} else {
  3643  			if minute > 14*60 {
  3644  				return moerr.NewWrongDatetimeSpec(ctx, tzStr)
  3645  			}
  3646  			sess.SetTimeZone(time.FixedZone("FixedZone", minute*60))
  3647  		}
  3648  
  3649  		vars[name] = tzStr
  3650  	} else {
  3651  		loc, err := time.LoadLocation(tzStr)
  3652  		if err != nil {
  3653  			return err
  3654  		}
  3655  
  3656  		vars[name] = tzStr
  3657  		sess.SetTimeZone(loc)
  3658  	}
  3659  
  3660  	return nil
  3661  }
  3662  
  3663  func getSystemTimeZone() string {
  3664  	tz, _ := time.Now().Zone()
  3665  	return tz
  3666  }
  3667  
  3668  func valueIsBoolTrue(value interface{}) (bool, error) {
  3669  	svbt := SystemVariableBoolType{}
  3670  	newValue, err2 := svbt.Convert(value)
  3671  	if err2 != nil {
  3672  		return false, err2
  3673  	}
  3674  	return svbt.IsTrue(newValue), nil
  3675  }
  3676  
  3677  type UserDefinedVar struct {
  3678  	Value interface{}
  3679  	Sql   string
  3680  }
  3681  
  3682  func autocommitValue(ctx context.Context, ses FeSession) (bool, error) {
  3683  	value, err := ses.GetSessionVar(ctx, "autocommit")
  3684  	if err != nil {
  3685  		return false, err
  3686  	}
  3687  	autocommit, err := valueIsBoolTrue(value)
  3688  	if err != nil {
  3689  		return false, err
  3690  	}
  3691  	return autocommit, err
  3692  }