From 54670d139a3728149b9636d736bcafe3730970fb Mon Sep 17 00:00:00 2001 From: hanchuanchuan Date: Sun, 12 Jun 2022 17:44:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feature:=20=E9=87=8D=E6=9E=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=BA=A7=E5=88=AB=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A8=A1?= =?UTF-8?q?=E5=9D=97,=E7=BA=A7=E5=88=AB=E5=AE=9E=E7=8E=B0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 7 +- config/config.go | 133 +------------ config/error_level.go | 309 +++++++++++++++++++++++++++++ config/error_level2.go | 353 +++++++++++++++++++++++++++++++++ config/generate_levels/main.go | 67 +++++++ go.mod | 4 +- go.sum | 26 +++ session/camel.go | 86 ++++++++ session/core.go | 1 + 9 files changed, 850 insertions(+), 136 deletions(-) create mode 100644 config/error_level.go create mode 100644 config/error_level2.go create mode 100644 config/generate_levels/main.go create mode 100644 session/camel.go diff --git a/Makefile b/Makefile index 7622487bd..e579dc0ce 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ CHECK_LDFLAGS += $(LDFLAGS) ${TEST_LDFLAGS} TARGET = "" -.PHONY: all build update parser clean todo test gotest interpreter server dev benchkv benchraw check parserlib checklist testapi docs +.PHONY: all build update parser clean todo test gotest interpreter server dev benchkv benchraw check parserlib checklist testapi docs level default: server buildsucc @@ -379,3 +379,8 @@ docker-push: docs: $(shell bash docs/deploy.sh) + +level: + @rm -f config/error_level.go + $(GO) run config/generate_levels/main.go + gofmt -w config/error_level.go diff --git a/config/config.go b/config/config.go index 7a0c95b69..981520ce3 100644 --- a/config/config.go +++ b/config/config.go @@ -610,73 +610,6 @@ type Ghost struct { GhostBinDir string `toml:"ghost_bin_dir" json:"ghost_bin_dir"` } -type IncLevel struct { - ER_ALTER_TABLE_ONCE int8 `toml:"er_alter_table_once"` - ER_AUTO_INCR_ID_WARNING int8 `toml:"er_auto_incr_id_warning"` - ER_AUTOINC_UNSIGNED int8 `toml:"er_autoinc_unsigned"` - ER_BLOB_CANT_HAVE_DEFAULT int8 `toml:"er_blob_cant_have_default"` - ER_CANT_SET_CHARSET int8 `toml:"er_cant_set_charset"` - ER_CANT_SET_COLLATION int8 `toml:"er_cant_set_collation"` - ER_CANT_SET_ENGINE int8 `toml:"er_cant_set_engine"` - ER_CHANGE_COLUMN_TYPE int8 `toml:"er_change_column_type"` - ER_CHANGE_TOO_MUCH_ROWS int8 `toml:"er_change_too_much_rows"` - ER_CHAR_TO_VARCHAR_LEN int8 `toml:"er_char_to_varchar_len"` - ER_CHARSET_ON_COLUMN int8 `toml:"er_charset_on_column"` - ER_COLUMN_HAVE_NO_COMMENT int8 `toml:"er_column_have_no_comment"` - ER_DATETIME_DEFAULT int8 `toml:"er_datetime_default"` - ErrFloatDoubleToDecimal int8 `toml:"er_float_double_to_decimal"` - ER_FOREIGN_KEY int8 `toml:"er_foreign_key"` - ER_IDENT_USE_KEYWORD int8 `toml:"er_ident_use_keyword"` - ER_INC_INIT_ERR int8 `toml:"er_inc_init_err"` - - ER_INDEX_NAME_IDX_PREFIX int8 `toml:"er_index_name_idx_prefix"` - ER_INDEX_NAME_UNIQ_PREFIX int8 `toml:"er_index_name_uniq_prefix"` - ER_INSERT_TOO_MUCH_ROWS int8 `toml:"er_insert_too_much_rows"` - ER_INVALID_DATA_TYPE int8 `toml:"er_invalid_data_type"` - ER_INVALID_IDENT int8 `toml:"er_invalid_ident"` - ErrMariaDBRollbackWarn int8 `toml:"er_mariadb_rollback_warn"` - ER_MUST_HAVE_COLUMNS int8 `toml:"er_must_have_columns"` - ErrColumnsMustHaveIndex int8 `toml:"er_columns_must_have_index"` - ErrColumnsMustHaveIndexTypeErr int8 `toml:"er_columns_must_have_index_type_err"` - ER_NO_WHERE_CONDITION int8 `toml:"er_no_where_condition"` - ER_NOT_ALLOWED_NULLABLE int8 `toml:"er_not_allowed_nullable"` - ER_ORDERY_BY_RAND int8 `toml:"er_ordery_by_rand"` - ER_PARTITION_NOT_ALLOWED int8 `toml:"er_partition_not_allowed"` - ER_PK_COLS_NOT_INT int8 `toml:"er_pk_cols_not_int"` - ER_PK_TOO_MANY_PARTS int8 `toml:"er_pk_too_many_parts"` - ER_SELECT_ONLY_STAR int8 `toml:"er_select_only_star"` - ER_SET_DATA_TYPE_INT_BIGINT int8 `toml:"er_set_data_type_int_bigint"` - ER_TABLE_CHARSET_MUST_NULL int8 `toml:"er_table_charset_must_null"` - ER_TABLE_CHARSET_MUST_UTF8 int8 `toml:"er_table_charset_must_utf8"` - ER_TABLE_MUST_HAVE_COMMENT int8 `toml:"er_table_must_have_comment"` - ER_TABLE_MUST_HAVE_PK int8 `toml:"er_table_must_have_pk"` - ER_TABLE_PREFIX int8 `toml:"er_table_prefix"` - ER_TEXT_NOT_NULLABLE_ERROR int8 `toml:"er_text_not_nullable_error"` - ER_TIMESTAMP_DEFAULT int8 `toml:"er_timestamp_default"` - ER_TOO_MANY_KEY_PARTS int8 `toml:"er_too_many_key_parts"` - ER_TOO_MANY_KEYS int8 `toml:"er_too_many_keys"` - ER_TOO_MUCH_AUTO_DATETIME_COLS int8 `toml:"er_too_much_auto_datetime_cols"` - ER_TOO_MUCH_AUTO_TIMESTAMP_COLS int8 `toml:"er_too_much_auto_timestamp_cols"` - ER_UDPATE_TOO_MUCH_ROWS int8 `toml:"er_udpate_too_much_rows"` - ER_USE_ENUM int8 `toml:"er_use_enum"` - ER_USE_TEXT_OR_BLOB int8 `toml:"er_use_text_or_blob"` - ER_WITH_DEFAULT_ADD_COLUMN int8 `toml:"er_with_default_add_column"` - ER_WITH_INSERT_FIELD int8 `toml:"er_with_insert_field"` - ER_WITH_LIMIT_CONDITION int8 `toml:"er_with_limit_condition"` - ER_WITH_ORDERBY_CONDITION int8 `toml:"er_with_orderby_condition"` - ErCantChangeColumn int8 `toml:"er_cant_change_column"` - ErCantChangeColumnPosition int8 `toml:"er_cant_change_column_position"` - ErJsonTypeSupport int8 `toml:"er_json_type_support"` - ErrImplicitTypeConversion int8 `toml:"er_implicit_type_conversion"` - ErrJoinNoOnCondition int8 `toml:"er_join_no_on_condition"` - ErrUseValueExpr int8 `toml:"er_use_value_expr"` - ErrWrongAndExpr int8 `toml:"er_wrong_and_expr"` - ErrViewSupport int8 `toml:"er_view_support"` - ErrIncorrectDateTimeValue int8 `toml:"er_incorrect_datetime_value"` - ErrMaxVarcharLength int8 `toml:"er_max_varchar_length"` - ErrMaxColumnCount int8 `toml:"er_max_column_count"` -} - var defaultConf = Config{ Host: "0.0.0.0", AdvertiseAddress: "", @@ -830,71 +763,7 @@ var defaultConf = Config{ GhostOkToDropTable: true, GhostSkipForeignKeyChecks: true, }, - IncLevel: IncLevel{ - ER_ALTER_TABLE_ONCE: 1, - ER_AUTO_INCR_ID_WARNING: 1, - ER_AUTOINC_UNSIGNED: 1, - ER_BLOB_CANT_HAVE_DEFAULT: 1, - ER_CANT_SET_CHARSET: 1, - ER_CANT_SET_COLLATION: 1, - ER_CANT_SET_ENGINE: 1, - ER_CHANGE_COLUMN_TYPE: 1, - ER_CHANGE_TOO_MUCH_ROWS: 1, - ER_CHAR_TO_VARCHAR_LEN: 1, - ER_CHARSET_ON_COLUMN: 1, - ER_COLUMN_HAVE_NO_COMMENT: 1, - ER_DATETIME_DEFAULT: 1, - ErrFloatDoubleToDecimal: 2, - ER_FOREIGN_KEY: 2, - ER_IDENT_USE_KEYWORD: 1, - ER_INC_INIT_ERR: 1, - ER_INDEX_NAME_IDX_PREFIX: 1, - ER_INDEX_NAME_UNIQ_PREFIX: 1, - ER_INSERT_TOO_MUCH_ROWS: 1, - ER_INVALID_DATA_TYPE: 1, - ER_INVALID_IDENT: 1, - ErrMariaDBRollbackWarn: 1, - ER_MUST_HAVE_COLUMNS: 1, - ErrColumnsMustHaveIndex: 1, - ErrColumnsMustHaveIndexTypeErr: 1, - ER_NO_WHERE_CONDITION: 1, - ER_NOT_ALLOWED_NULLABLE: 1, - ER_ORDERY_BY_RAND: 1, - ER_PARTITION_NOT_ALLOWED: 1, - ER_PK_COLS_NOT_INT: 1, - ER_PK_TOO_MANY_PARTS: 1, - ER_SELECT_ONLY_STAR: 1, - ER_SET_DATA_TYPE_INT_BIGINT: 2, - ER_TABLE_CHARSET_MUST_NULL: 1, - ER_TABLE_CHARSET_MUST_UTF8: 1, - ER_TABLE_MUST_HAVE_COMMENT: 1, - ER_TABLE_MUST_HAVE_PK: 1, - ER_TABLE_PREFIX: 1, - ER_TEXT_NOT_NULLABLE_ERROR: 1, - ER_TIMESTAMP_DEFAULT: 1, - ER_TOO_MANY_KEY_PARTS: 1, - ER_TOO_MANY_KEYS: 1, - ER_TOO_MUCH_AUTO_DATETIME_COLS: 2, - ER_TOO_MUCH_AUTO_TIMESTAMP_COLS: 2, - ER_UDPATE_TOO_MUCH_ROWS: 1, - ER_USE_ENUM: 1, - ER_USE_TEXT_OR_BLOB: 2, - ER_WITH_DEFAULT_ADD_COLUMN: 1, - ER_WITH_INSERT_FIELD: 1, - ER_WITH_LIMIT_CONDITION: 1, - ER_WITH_ORDERBY_CONDITION: 1, - ErCantChangeColumn: 1, - ErCantChangeColumnPosition: 1, - ErJsonTypeSupport: 2, - ErrImplicitTypeConversion: 1, - ErrJoinNoOnCondition: 1, - ErrUseValueExpr: 1, - ErrWrongAndExpr: 1, - ErrViewSupport: 2, - ErrIncorrectDateTimeValue: 2, - ErrMaxVarcharLength: 2, - ErrMaxColumnCount: 1, - }, + IncLevel: defaultLevel, } var globalConf = defaultConf diff --git a/config/error_level.go b/config/error_level.go new file mode 100644 index 000000000..6a353e03b --- /dev/null +++ b/config/error_level.go @@ -0,0 +1,309 @@ +package config + +type IncLevel struct { + ER_ALTER_TABLE_ONCE int8 `toml:"er_alter_table_once"` + ER_AUTO_INCR_ID_WARNING int8 `toml:"er_auto_incr_id_warning"` + ER_AUTOINC_UNSIGNED int8 `toml:"er_autoinc_unsigned"` + ER_BLOB_CANT_HAVE_DEFAULT int8 `toml:"er_blob_cant_have_default"` + ER_CANT_SET_CHARSET int8 `toml:"er_cant_set_charset"` + ER_CANT_SET_COLLATION int8 `toml:"er_cant_set_collation"` + ER_CANT_SET_ENGINE int8 `toml:"er_cant_set_engine"` + ER_CHANGE_COLUMN_TYPE int8 `toml:"er_change_column_type"` + ER_CHANGE_TOO_MUCH_ROWS int8 `toml:"er_change_too_much_rows"` + ER_CHAR_TO_VARCHAR_LEN int8 `toml:"er_char_to_varchar_len"` + ER_CHARSET_ON_COLUMN int8 `toml:"er_charset_on_column"` + ER_COLUMN_HAVE_NO_COMMENT int8 `toml:"er_column_have_no_comment"` + ER_DATETIME_DEFAULT int8 `toml:"er_datetime_default"` + ErrFloatDoubleToDecimal int8 `toml:"er_float_double_to_decimal"` + ER_FOREIGN_KEY int8 `toml:"er_foreign_key"` + ER_IDENT_USE_KEYWORD int8 `toml:"er_ident_use_keyword"` + ER_INC_INIT_ERR int8 `toml:"er_inc_init_err"` + + ER_INDEX_NAME_IDX_PREFIX int8 `toml:"er_index_name_idx_prefix"` + ER_INDEX_NAME_UNIQ_PREFIX int8 `toml:"er_index_name_uniq_prefix"` + ER_INSERT_TOO_MUCH_ROWS int8 `toml:"er_insert_too_much_rows"` + ER_INVALID_DATA_TYPE int8 `toml:"er_invalid_data_type"` + ER_INVALID_IDENT int8 `toml:"er_invalid_ident"` + ErrMariaDBRollbackWarn int8 `toml:"er_mariadb_rollback_warn"` + ER_MUST_HAVE_COLUMNS int8 `toml:"er_must_have_columns"` + ErrColumnsMustHaveIndex int8 `toml:"er_columns_must_have_index"` + ErrColumnsMustHaveIndexTypeErr int8 `toml:"er_columns_must_have_index_type_err"` + ER_NO_WHERE_CONDITION int8 `toml:"er_no_where_condition"` + ER_NOT_ALLOWED_NULLABLE int8 `toml:"er_not_allowed_nullable"` + ER_ORDERY_BY_RAND int8 `toml:"er_ordery_by_rand"` + ER_PARTITION_NOT_ALLOWED int8 `toml:"er_partition_not_allowed"` + ER_PK_COLS_NOT_INT int8 `toml:"er_pk_cols_not_int"` + ER_PK_TOO_MANY_PARTS int8 `toml:"er_pk_too_many_parts"` + ER_SELECT_ONLY_STAR int8 `toml:"er_select_only_star"` + ER_SET_DATA_TYPE_INT_BIGINT int8 `toml:"er_set_data_type_int_bigint"` + ER_TABLE_CHARSET_MUST_NULL int8 `toml:"er_table_charset_must_null"` + ER_TABLE_CHARSET_MUST_UTF8 int8 `toml:"er_table_charset_must_utf8"` + ER_TABLE_MUST_HAVE_COMMENT int8 `toml:"er_table_must_have_comment"` + ER_TABLE_MUST_HAVE_PK int8 `toml:"er_table_must_have_pk"` + ER_TABLE_PREFIX int8 `toml:"er_table_prefix"` + ER_TEXT_NOT_NULLABLE_ERROR int8 `toml:"er_text_not_nullable_error"` + ER_TIMESTAMP_DEFAULT int8 `toml:"er_timestamp_default"` + ER_TOO_MANY_KEY_PARTS int8 `toml:"er_too_many_key_parts"` + ER_TOO_MANY_KEYS int8 `toml:"er_too_many_keys"` + ER_TOO_MUCH_AUTO_DATETIME_COLS int8 `toml:"er_too_much_auto_datetime_cols"` + ER_TOO_MUCH_AUTO_TIMESTAMP_COLS int8 `toml:"er_too_much_auto_timestamp_cols"` + ER_UDPATE_TOO_MUCH_ROWS int8 `toml:"er_udpate_too_much_rows"` + ER_USE_ENUM int8 `toml:"er_use_enum"` + ER_USE_TEXT_OR_BLOB int8 `toml:"er_use_text_or_blob"` + ER_WITH_DEFAULT_ADD_COLUMN int8 `toml:"er_with_default_add_column"` + ER_WITH_INSERT_FIELD int8 `toml:"er_with_insert_field"` + ER_WITH_LIMIT_CONDITION int8 `toml:"er_with_limit_condition"` + ER_WITH_ORDERBY_CONDITION int8 `toml:"er_with_orderby_condition"` + ErCantChangeColumn int8 `toml:"er_cant_change_column"` + ErCantChangeColumnPosition int8 `toml:"er_cant_change_column_position"` + ErJsonTypeSupport int8 `toml:"er_json_type_support"` + ErrImplicitTypeConversion int8 `toml:"er_implicit_type_conversion"` + ErrJoinNoOnCondition int8 `toml:"er_join_no_on_condition"` + ErrUseValueExpr int8 `toml:"er_use_value_expr"` + ErrWrongAndExpr int8 `toml:"er_wrong_and_expr"` + ErrViewSupport int8 `toml:"er_view_support"` + ErrIncorrectDateTimeValue int8 `toml:"er_incorrect_datetime_value"` + ErrMaxVarcharLength int8 `toml:"er_max_varchar_length"` + ErrMaxColumnCount int8 `toml:"er_max_column_count"` +} + +var DefaultLevel = IncLevel2{ + ErAlterTableOnce: 1, + ErAutoIncrIdWarning: 1, + ErAutoincUnsigned: 1, + ErBadFieldError: 2, + ErBadNullError: 2, + ErBinlogCorrupted: 2, + ErBinlogFormatStatement: 2, + ErBlobCantHaveDefault: 1, + ErBlobUsedAsKey: 2, + ErCantChangeColumn: 1, + ErCantChangeColumnPosition: 1, + ErCantDropDatabase: 2, + ErCantDropFieldOrKey: 2, + ErCantDropTable: 2, + ErCantRemoveAllFields: 2, + ErCantSetCharset: 1, + ErCantSetCollation: 1, + ErCantSetEngine: 1, + ErChangeColumnType: 1, + ErChangeTooMuchRows: 1, + ErCharToVarcharLen: 1, + ErCharsetNotSupport: 2, + ErCharsetOnColumn: 1, + ErCollationCharsetMismatch: 2, + ErCollationNotSupport: 2, + ErColumnExisted: 2, + ErColumnHaveNoComment: 1, + ErColumnNotExisted: 2, + ErColumnsMustHaveIndex: 1, + ErColumnsMustHaveIndexTypeErr: 1, + ErConCountError: 2, + ErConflictingDeclarations: 2, + ErDataTooLong: 2, + ErDbNotExistedError: 2, + ErDdlDmlCoexist: 2, + ErDupFieldname: 2, + ErDupIndex: 2, + ErDupKeyname: 2, + ErEndWithCommit: 2, + ErEndWithSemicolon: 2, + ErEngineNotSupport: 2, + ErErrorExistBefore: 2, + ErFieldNotInGroupBy: 2, + ErFieldSpecifiedTwice: 2, + ErFloatDoubleToDecimal: 2, + ErForcingClose: 2, + ErForeignKey: 2, + ErHaveBegin: 2, + ErHostname: 2, + ErIdIsUper: 2, + ErIdentUseKeyword: 1, + ErIdentifierLower: 2, + ErIdentifierUpper: 2, + ErImplicitTypeConversion: 1, + ErIncInitErr: 1, + ErInceptionEmptyQuery: 2, + ErIncorrectDatetimeValue: 2, + ErIncorrectGlobalLocalVar: 2, + ErIndexNameIdxPrefix: 1, + ErIndexNameUniqPrefix: 1, + ErIndexUseAlterTable: 2, + ErInsertTooMuchRows: 1, + ErInvalidBackupHostInfo: 2, + ErInvalidCommand: 2, + ErInvalidDataType: 1, + ErInvalidDefault: 2, + ErInvalidGroupFuncUse: 2, + ErInvalidIdent: 1, + ErInvalidOnUpdate: 2, + ErJoinNoOnCondition: 1, + ErJsonTypeSupport: 2, + ErKeyColumnDoesNotExits: 2, + ErMariadbRollbackWarn: 1, + ErMaxColumnCount: 1, + ErMaxVarcharLength: 2, + ErMixOfGroupFuncAndFields: 2, + ErMultiplePriKey: 2, + ErMustAtLeastOneColumn: 2, + ErMustHaveColumns: 1, + ErNetPacketsOutOfOrder: 2, + ErNetReadError: 2, + ErNetReadInterrupted: 2, + ErNetworkReadEventChecksumFailure: 2, + ErNoDbError: 2, + ErNoWhereCondition: 1, + ErNonUniqError: 2, + ErNonUniqTable: 2, + ErNormalShutdown: 2, + ErNotAllowedNullable: 1, + ErNotFoundMasterStatus: 2, + ErNotFoundTableInfo: 1, + ErNotSupportedAlterOption: 1, + ErNotSupportedItemType: 2, + ErNotSupportedKeyType: 2, + ErNotSupportedYet: 2, + ErNotValidPassword: 2, + ErOrderyByRand: 1, + ErOscKillFailed: 2, + ErOutofmemory: 1, + ErParseError: 2, + ErPartitionNotAllowed: 1, + ErPartitionNotExisted: 2, + ErPkColsNotInt: 1, + ErPkTooManyParts: 1, + ErPrimaryCantHaveNull: 2, + ErRemoteExeError: 2, + ErRemovedSpaces: 2, + ErRepeatConstDefinition: 2, + ErSameNamePartition: 2, + ErSelectOnlyStar: 1, + ErSetDataTypeIntBigint: 2, + ErShutdownComplete: 2, + ErSlaveCorruptEvent: 2, + ErSlaveRelayLogWriteFailure: 2, + ErSqlInvalidOpType: 2, + ErSqlInvalidSource: 2, + ErSqlNoOpType: 2, + ErSqlNoSource: 2, + ErStartAsBegin: 2, + ErSyntaxError: 2, + ErTableCantHandleAutoIncrement: 2, + ErTableCharsetMustNull: 1, + ErTableCharsetMustUtf8: 1, + ErTableCollationNotSupport: 1, + ErTableExistsError: 2, + ErTableMustHaveComment: 1, + ErTableMustHavePk: 1, + ErTableNotExistedError: 2, + ErTablePrefix: 1, + ErTempTableTmpPrefix: 1, + ErTextNotNullableError: 1, + ErTimestampDefault: 1, + ErTooLongBakdbName: 2, + ErTooLongIdent: 2, + ErTooLongIndexComment: 1, + ErTooLongKey: 2, + ErTooManyKeyParts: 1, + ErTooManyKeys: 1, + ErTooMuchAutoTimestampCols: 2, + ErTruncatedWrongValue: 2, + ErUdpateTooMuchRows: 1, + ErUnknownCharacterSet: 2, + ErUnknownCharset: 1, + ErUnknownCollation: 1, + ErUnknownSystemVariable: 2, + ErUnknownTable: 2, + ErUseEnum: 1, + ErUseIndexVisibility: 2, + ErUseTextOrBlob: 2, + ErUseValueExpr: 1, + ErUsername: 2, + ErVarcharToTextLen: 2, + ErViewSelectClause: 2, + ErViewSupport: 2, + ErWithDefaultAddColumn: 1, + ErWithInsertField: 1, + ErWithInsertValues: 2, + ErWithLimitCondition: 1, + ErWithOrderbyCondition: 1, + ErWrongAndExpr: 1, + ErWrongArguments: 2, + ErWrongAutoKey: 2, + ErWrongColumnName: 2, + ErWrongDbName: 2, + ErWrongKeyColumn: 2, + ErWrongNameForIndex: 2, + ErWrongStringLength: 2, + ErWrongSubKey: 2, + ErWrongTableName: 2, + ErWrongUsage: 2, + ErWrongValueCountOnRow: 2, + ErWrongValueForVar: 2, +} + +var defaultLevel = IncLevel{ + ER_ALTER_TABLE_ONCE: 1, + ER_AUTO_INCR_ID_WARNING: 1, + ER_AUTOINC_UNSIGNED: 1, + ER_BLOB_CANT_HAVE_DEFAULT: 1, + ER_CANT_SET_CHARSET: 1, + ER_CANT_SET_COLLATION: 1, + ER_CANT_SET_ENGINE: 1, + ER_CHANGE_COLUMN_TYPE: 1, + ER_CHANGE_TOO_MUCH_ROWS: 1, + ER_CHAR_TO_VARCHAR_LEN: 1, + ER_CHARSET_ON_COLUMN: 1, + ER_COLUMN_HAVE_NO_COMMENT: 1, + ER_DATETIME_DEFAULT: 1, + ErrFloatDoubleToDecimal: 2, + ER_FOREIGN_KEY: 2, + ER_IDENT_USE_KEYWORD: 1, + ER_INC_INIT_ERR: 1, + ER_INDEX_NAME_IDX_PREFIX: 1, + ER_INDEX_NAME_UNIQ_PREFIX: 1, + ER_INSERT_TOO_MUCH_ROWS: 1, + ER_INVALID_DATA_TYPE: 1, + ER_INVALID_IDENT: 1, + ErrMariaDBRollbackWarn: 1, + ER_MUST_HAVE_COLUMNS: 1, + ErrColumnsMustHaveIndex: 1, + ErrColumnsMustHaveIndexTypeErr: 1, + ER_NO_WHERE_CONDITION: 1, + ER_NOT_ALLOWED_NULLABLE: 1, + ER_ORDERY_BY_RAND: 1, + ER_PARTITION_NOT_ALLOWED: 1, + ER_PK_COLS_NOT_INT: 1, + ER_PK_TOO_MANY_PARTS: 1, + ER_SELECT_ONLY_STAR: 1, + ER_SET_DATA_TYPE_INT_BIGINT: 2, + ER_TABLE_CHARSET_MUST_NULL: 1, + ER_TABLE_CHARSET_MUST_UTF8: 1, + ER_TABLE_MUST_HAVE_COMMENT: 1, + ER_TABLE_MUST_HAVE_PK: 1, + ER_TABLE_PREFIX: 1, + ER_TEXT_NOT_NULLABLE_ERROR: 1, + ER_TIMESTAMP_DEFAULT: 1, + ER_TOO_MANY_KEY_PARTS: 1, + ER_TOO_MANY_KEYS: 1, + ER_TOO_MUCH_AUTO_DATETIME_COLS: 2, + ER_TOO_MUCH_AUTO_TIMESTAMP_COLS: 2, + ER_UDPATE_TOO_MUCH_ROWS: 1, + ER_USE_ENUM: 1, + ER_USE_TEXT_OR_BLOB: 2, + ER_WITH_DEFAULT_ADD_COLUMN: 1, + ER_WITH_INSERT_FIELD: 1, + ER_WITH_LIMIT_CONDITION: 1, + ER_WITH_ORDERBY_CONDITION: 1, + ErCantChangeColumn: 1, + ErCantChangeColumnPosition: 1, + ErJsonTypeSupport: 2, + ErrImplicitTypeConversion: 1, + ErrJoinNoOnCondition: 1, + ErrUseValueExpr: 1, + ErrWrongAndExpr: 1, + ErrViewSupport: 2, + ErrIncorrectDateTimeValue: 2, + ErrMaxVarcharLength: 2, + ErrMaxColumnCount: 1, +} diff --git a/config/error_level2.go b/config/error_level2.go new file mode 100644 index 000000000..4573a7ed3 --- /dev/null +++ b/config/error_level2.go @@ -0,0 +1,353 @@ +// Code generated by make level. DO NOT EDIT. + +package config + +type IncLevel2 struct { + ErAlterTableOnce uint8 `toml:"er_alter_table_once"` + ErAutoIncrIdWarning uint8 `toml:"er_auto_incr_id_warning"` + ErAutoincUnsigned uint8 `toml:"er_autoinc_unsigned"` + ErBadFieldError uint8 `toml:"er_bad_field_error"` + ErBadNullError uint8 `toml:"er_bad_null_error"` + ErBinlogCorrupted uint8 `toml:"er_binlog_corrupted"` + ErBinlogFormatStatement uint8 `toml:"er_binlog_format_statement"` + ErBlobCantHaveDefault uint8 `toml:"er_blob_cant_have_default"` + ErBlobUsedAsKey uint8 `toml:"er_blob_used_as_key"` + ErCantChangeColumn uint8 `toml:"er_cant_change_column"` + ErCantChangeColumnPosition uint8 `toml:"er_cant_change_column_position"` + ErCantDropDatabase uint8 `toml:"er_cant_drop_database"` + ErCantDropFieldOrKey uint8 `toml:"er_cant_drop_field_or_key"` + ErCantDropTable uint8 `toml:"er_cant_drop_table"` + ErCantRemoveAllFields uint8 `toml:"er_cant_remove_all_fields"` + ErCantSetCharset uint8 `toml:"er_cant_set_charset"` + ErCantSetCollation uint8 `toml:"er_cant_set_collation"` + ErCantSetEngine uint8 `toml:"er_cant_set_engine"` + ErChangeColumnType uint8 `toml:"er_change_column_type"` + ErChangeTooMuchRows uint8 `toml:"er_change_too_much_rows"` + ErCharToVarcharLen uint8 `toml:"er_char_to_varchar_len"` + ErCharsetNotSupport uint8 `toml:"er_charset_not_support"` + ErCharsetOnColumn uint8 `toml:"er_charset_on_column"` + ErCollationCharsetMismatch uint8 `toml:"er_collation_charset_mismatch"` + ErCollationNotSupport uint8 `toml:"er_collation_not_support"` + ErColumnExisted uint8 `toml:"er_column_existed"` + ErColumnHaveNoComment uint8 `toml:"er_column_have_no_comment"` + ErColumnNotExisted uint8 `toml:"er_column_not_existed"` + ErColumnsMustHaveIndex uint8 `toml:"er_columns_must_have_index"` + ErColumnsMustHaveIndexTypeErr uint8 `toml:"er_columns_must_have_index_type_err"` + ErConCountError uint8 `toml:"er_con_count_error"` + ErConflictingDeclarations uint8 `toml:"er_conflicting_declarations"` + ErDataTooLong uint8 `toml:"er_data_too_long"` + ErDbNotExistedError uint8 `toml:"er_db_not_existed_error"` + ErDdlDmlCoexist uint8 `toml:"er_ddl_dml_coexist"` + ErDupFieldname uint8 `toml:"er_dup_fieldname"` + ErDupIndex uint8 `toml:"er_dup_index"` + ErDupKeyname uint8 `toml:"er_dup_keyname"` + ErEndWithCommit uint8 `toml:"er_end_with_commit"` + ErEndWithSemicolon uint8 `toml:"er_end_with_semicolon"` + ErEngineNotSupport uint8 `toml:"er_engine_not_support"` + ErErrorExistBefore uint8 `toml:"er_error_exist_before"` + ErFieldNotInGroupBy uint8 `toml:"er_field_not_in_group_by"` + ErFieldSpecifiedTwice uint8 `toml:"er_field_specified_twice"` + ErFloatDoubleToDecimal uint8 `toml:"er_float_double_to_decimal"` + ErForcingClose uint8 `toml:"er_forcing_close"` + ErForeignKey uint8 `toml:"er_foreign_key"` + ErHaveBegin uint8 `toml:"er_have_begin"` + ErHostname uint8 `toml:"er_hostname"` + ErIdIsUper uint8 `toml:"er_id_is_uper"` + ErIdentUseKeyword uint8 `toml:"er_ident_use_keyword"` + ErIdentifierLower uint8 `toml:"er_identifier_lower"` + ErIdentifierUpper uint8 `toml:"er_identifier_upper"` + ErImplicitTypeConversion uint8 `toml:"er_implicit_type_conversion"` + ErIncInitErr uint8 `toml:"er_inc_init_err"` + ErInceptionEmptyQuery uint8 `toml:"er_inception_empty_query"` + ErIncorrectDatetimeValue uint8 `toml:"er_incorrect_datetime_value"` + ErIncorrectGlobalLocalVar uint8 `toml:"er_incorrect_global_local_var"` + ErIndexNameIdxPrefix uint8 `toml:"er_index_name_idx_prefix"` + ErIndexNameUniqPrefix uint8 `toml:"er_index_name_uniq_prefix"` + ErIndexUseAlterTable uint8 `toml:"er_index_use_alter_table"` + ErInsertTooMuchRows uint8 `toml:"er_insert_too_much_rows"` + ErInvalidBackupHostInfo uint8 `toml:"er_invalid_backup_host_info"` + ErInvalidCommand uint8 `toml:"er_invalid_command"` + ErInvalidDataType uint8 `toml:"er_invalid_data_type"` + ErInvalidDefault uint8 `toml:"er_invalid_default"` + ErInvalidGroupFuncUse uint8 `toml:"er_invalid_group_func_use"` + ErInvalidIdent uint8 `toml:"er_invalid_ident"` + ErInvalidOnUpdate uint8 `toml:"er_invalid_on_update"` + ErJoinNoOnCondition uint8 `toml:"er_join_no_on_condition"` + ErJsonTypeSupport uint8 `toml:"er_json_type_support"` + ErKeyColumnDoesNotExits uint8 `toml:"er_key_column_does_not_exits"` + ErMariadbRollbackWarn uint8 `toml:"er_mariadb_rollback_warn"` + ErMaxColumnCount uint8 `toml:"er_max_column_count"` + ErMaxVarcharLength uint8 `toml:"er_max_varchar_length"` + ErMixOfGroupFuncAndFields uint8 `toml:"er_mix_of_group_func_and_fields"` + ErMultiplePriKey uint8 `toml:"er_multiple_pri_key"` + ErMustAtLeastOneColumn uint8 `toml:"er_must_at_least_one_column"` + ErMustHaveColumns uint8 `toml:"er_must_have_columns"` + ErNetPacketsOutOfOrder uint8 `toml:"er_net_packets_out_of_order"` + ErNetReadError uint8 `toml:"er_net_read_error"` + ErNetReadInterrupted uint8 `toml:"er_net_read_interrupted"` + ErNetworkReadEventChecksumFailure uint8 `toml:"er_network_read_event_checksum_failure"` + ErNoDbError uint8 `toml:"er_no_db_error"` + ErNoWhereCondition uint8 `toml:"er_no_where_condition"` + ErNonUniqError uint8 `toml:"er_non_uniq_error"` + ErNonUniqTable uint8 `toml:"er_non_uniq_table"` + ErNormalShutdown uint8 `toml:"er_normal_shutdown"` + ErNotAllowedNullable uint8 `toml:"er_not_allowed_nullable"` + ErNotFoundMasterStatus uint8 `toml:"er_not_found_master_status"` + ErNotFoundTableInfo uint8 `toml:"er_not_found_table_info"` + ErNotSupportedAlterOption uint8 `toml:"er_not_supported_alter_option"` + ErNotSupportedItemType uint8 `toml:"er_not_supported_item_type"` + ErNotSupportedKeyType uint8 `toml:"er_not_supported_key_type"` + ErNotSupportedYet uint8 `toml:"er_not_supported_yet"` + ErNotValidPassword uint8 `toml:"er_not_valid_password"` + ErOrderyByRand uint8 `toml:"er_ordery_by_rand"` + ErOscKillFailed uint8 `toml:"er_osc_kill_failed"` + ErOutofmemory uint8 `toml:"er_outofmemory"` + ErParseError uint8 `toml:"er_parse_error"` + ErPartitionNotAllowed uint8 `toml:"er_partition_not_allowed"` + ErPartitionNotExisted uint8 `toml:"er_partition_not_existed"` + ErPkColsNotInt uint8 `toml:"er_pk_cols_not_int"` + ErPkTooManyParts uint8 `toml:"er_pk_too_many_parts"` + ErPrimaryCantHaveNull uint8 `toml:"er_primary_cant_have_null"` + ErRemoteExeError uint8 `toml:"er_remote_exe_error"` + ErRemovedSpaces uint8 `toml:"er_removed_spaces"` + ErRepeatConstDefinition uint8 `toml:"er_repeat_const_definition"` + ErSameNamePartition uint8 `toml:"er_same_name_partition"` + ErSelectOnlyStar uint8 `toml:"er_select_only_star"` + ErSetDataTypeIntBigint uint8 `toml:"er_set_data_type_int_bigint"` + ErShutdownComplete uint8 `toml:"er_shutdown_complete"` + ErSlaveCorruptEvent uint8 `toml:"er_slave_corrupt_event"` + ErSlaveRelayLogWriteFailure uint8 `toml:"er_slave_relay_log_write_failure"` + ErSqlInvalidOpType uint8 `toml:"er_sql_invalid_op_type"` + ErSqlInvalidSource uint8 `toml:"er_sql_invalid_source"` + ErSqlNoOpType uint8 `toml:"er_sql_no_op_type"` + ErSqlNoSource uint8 `toml:"er_sql_no_source"` + ErStartAsBegin uint8 `toml:"er_start_as_begin"` + ErSyntaxError uint8 `toml:"er_syntax_error"` + ErTableCantHandleAutoIncrement uint8 `toml:"er_table_cant_handle_auto_increment"` + ErTableCharsetMustNull uint8 `toml:"er_table_charset_must_null"` + ErTableCharsetMustUtf8 uint8 `toml:"er_table_charset_must_utf8"` + ErTableCollationNotSupport uint8 `toml:"er_table_collation_not_support"` + ErTableExistsError uint8 `toml:"er_table_exists_error"` + ErTableMustHaveComment uint8 `toml:"er_table_must_have_comment"` + ErTableMustHavePk uint8 `toml:"er_table_must_have_pk"` + ErTableNotExistedError uint8 `toml:"er_table_not_existed_error"` + ErTablePrefix uint8 `toml:"er_table_prefix"` + ErTempTableTmpPrefix uint8 `toml:"er_temp_table_tmp_prefix"` + ErTextNotNullableError uint8 `toml:"er_text_not_nullable_error"` + ErTimestampDefault uint8 `toml:"er_timestamp_default"` + ErTooLongBakdbName uint8 `toml:"er_too_long_bakdb_name"` + ErTooLongIdent uint8 `toml:"er_too_long_ident"` + ErTooLongIndexComment uint8 `toml:"er_too_long_index_comment"` + ErTooLongKey uint8 `toml:"er_too_long_key"` + ErTooManyKeyParts uint8 `toml:"er_too_many_key_parts"` + ErTooManyKeys uint8 `toml:"er_too_many_keys"` + ErTooMuchAutoTimestampCols uint8 `toml:"er_too_much_auto_timestamp_cols"` + ErTruncatedWrongValue uint8 `toml:"er_truncated_wrong_value"` + ErUdpateTooMuchRows uint8 `toml:"er_udpate_too_much_rows"` + ErUnknownCharacterSet uint8 `toml:"er_unknown_character_set"` + ErUnknownCharset uint8 `toml:"er_unknown_charset"` + ErUnknownCollation uint8 `toml:"er_unknown_collation"` + ErUnknownSystemVariable uint8 `toml:"er_unknown_system_variable"` + ErUnknownTable uint8 `toml:"er_unknown_table"` + ErUseEnum uint8 `toml:"er_use_enum"` + ErUseIndexVisibility uint8 `toml:"er_use_index_visibility"` + ErUseTextOrBlob uint8 `toml:"er_use_text_or_blob"` + ErUseValueExpr uint8 `toml:"er_use_value_expr"` + ErUsername uint8 `toml:"er_username"` + ErVarcharToTextLen uint8 `toml:"er_varchar_to_text_len"` + ErViewSelectClause uint8 `toml:"er_view_select_clause"` + ErViewSupport uint8 `toml:"er_view_support"` + ErWithDefaultAddColumn uint8 `toml:"er_with_default_add_column"` + ErWithInsertField uint8 `toml:"er_with_insert_field"` + ErWithInsertValues uint8 `toml:"er_with_insert_values"` + ErWithLimitCondition uint8 `toml:"er_with_limit_condition"` + ErWithOrderbyCondition uint8 `toml:"er_with_orderby_condition"` + ErWrongAndExpr uint8 `toml:"er_wrong_and_expr"` + ErWrongArguments uint8 `toml:"er_wrong_arguments"` + ErWrongAutoKey uint8 `toml:"er_wrong_auto_key"` + ErWrongColumnName uint8 `toml:"er_wrong_column_name"` + ErWrongDbName uint8 `toml:"er_wrong_db_name"` + ErWrongKeyColumn uint8 `toml:"er_wrong_key_column"` + ErWrongNameForIndex uint8 `toml:"er_wrong_name_for_index"` + ErWrongStringLength uint8 `toml:"er_wrong_string_length"` + ErWrongSubKey uint8 `toml:"er_wrong_sub_key"` + ErWrongTableName uint8 `toml:"er_wrong_table_name"` + ErWrongUsage uint8 `toml:"er_wrong_usage"` + ErWrongValueCountOnRow uint8 `toml:"er_wrong_value_count_on_row"` + ErWrongValueForVar uint8 `toml:"er_wrong_value_for_var"` +} + +var DefaultLevel = IncLevel2{ + ErAlterTableOnce: 1, + ErAutoIncrIdWarning: 1, + ErAutoincUnsigned: 1, + ErBadFieldError: 2, + ErBadNullError: 2, + ErBinlogCorrupted: 2, + ErBinlogFormatStatement: 2, + ErBlobCantHaveDefault: 1, + ErBlobUsedAsKey: 2, + ErCantChangeColumn: 1, + ErCantChangeColumnPosition: 1, + ErCantDropDatabase: 2, + ErCantDropFieldOrKey: 2, + ErCantDropTable: 2, + ErCantRemoveAllFields: 2, + ErCantSetCharset: 1, + ErCantSetCollation: 1, + ErCantSetEngine: 1, + ErChangeColumnType: 1, + ErChangeTooMuchRows: 1, + ErCharToVarcharLen: 1, + ErCharsetNotSupport: 2, + ErCharsetOnColumn: 1, + ErCollationCharsetMismatch: 2, + ErCollationNotSupport: 2, + ErColumnExisted: 2, + ErColumnHaveNoComment: 1, + ErColumnNotExisted: 2, + ErColumnsMustHaveIndex: 1, + ErColumnsMustHaveIndexTypeErr: 1, + ErConCountError: 2, + ErConflictingDeclarations: 2, + ErDataTooLong: 2, + ErDbNotExistedError: 2, + ErDdlDmlCoexist: 2, + ErDupFieldname: 2, + ErDupIndex: 2, + ErDupKeyname: 2, + ErEndWithCommit: 2, + ErEndWithSemicolon: 2, + ErEngineNotSupport: 2, + ErErrorExistBefore: 2, + ErFieldNotInGroupBy: 2, + ErFieldSpecifiedTwice: 2, + ErFloatDoubleToDecimal: 2, + ErForcingClose: 2, + ErForeignKey: 2, + ErHaveBegin: 2, + ErHostname: 2, + ErIdIsUper: 2, + ErIdentUseKeyword: 1, + ErIdentifierLower: 2, + ErIdentifierUpper: 2, + ErImplicitTypeConversion: 1, + ErIncInitErr: 1, + ErInceptionEmptyQuery: 2, + ErIncorrectDatetimeValue: 2, + ErIncorrectGlobalLocalVar: 2, + ErIndexNameIdxPrefix: 1, + ErIndexNameUniqPrefix: 1, + ErIndexUseAlterTable: 2, + ErInsertTooMuchRows: 1, + ErInvalidBackupHostInfo: 2, + ErInvalidCommand: 2, + ErInvalidDataType: 1, + ErInvalidDefault: 2, + ErInvalidGroupFuncUse: 2, + ErInvalidIdent: 1, + ErInvalidOnUpdate: 2, + ErJoinNoOnCondition: 1, + ErJsonTypeSupport: 2, + ErKeyColumnDoesNotExits: 2, + ErMariadbRollbackWarn: 1, + ErMaxColumnCount: 1, + ErMaxVarcharLength: 2, + ErMixOfGroupFuncAndFields: 2, + ErMultiplePriKey: 2, + ErMustAtLeastOneColumn: 2, + ErMustHaveColumns: 1, + ErNetPacketsOutOfOrder: 2, + ErNetReadError: 2, + ErNetReadInterrupted: 2, + ErNetworkReadEventChecksumFailure: 2, + ErNoDbError: 2, + ErNoWhereCondition: 1, + ErNonUniqError: 2, + ErNonUniqTable: 2, + ErNormalShutdown: 2, + ErNotAllowedNullable: 1, + ErNotFoundMasterStatus: 2, + ErNotFoundTableInfo: 1, + ErNotSupportedAlterOption: 1, + ErNotSupportedItemType: 2, + ErNotSupportedKeyType: 2, + ErNotSupportedYet: 2, + ErNotValidPassword: 2, + ErOrderyByRand: 1, + ErOscKillFailed: 2, + ErOutofmemory: 1, + ErParseError: 2, + ErPartitionNotAllowed: 1, + ErPartitionNotExisted: 2, + ErPkColsNotInt: 1, + ErPkTooManyParts: 1, + ErPrimaryCantHaveNull: 2, + ErRemoteExeError: 2, + ErRemovedSpaces: 2, + ErRepeatConstDefinition: 2, + ErSameNamePartition: 2, + ErSelectOnlyStar: 1, + ErSetDataTypeIntBigint: 2, + ErShutdownComplete: 2, + ErSlaveCorruptEvent: 2, + ErSlaveRelayLogWriteFailure: 2, + ErSqlInvalidOpType: 2, + ErSqlInvalidSource: 2, + ErSqlNoOpType: 2, + ErSqlNoSource: 2, + ErStartAsBegin: 2, + ErSyntaxError: 2, + ErTableCantHandleAutoIncrement: 2, + ErTableCharsetMustNull: 1, + ErTableCharsetMustUtf8: 1, + ErTableCollationNotSupport: 1, + ErTableExistsError: 2, + ErTableMustHaveComment: 1, + ErTableMustHavePk: 1, + ErTableNotExistedError: 2, + ErTablePrefix: 1, + ErTempTableTmpPrefix: 1, + ErTextNotNullableError: 1, + ErTimestampDefault: 1, + ErTooLongBakdbName: 2, + ErTooLongIdent: 2, + ErTooLongIndexComment: 1, + ErTooLongKey: 2, + ErTooManyKeyParts: 1, + ErTooManyKeys: 1, + ErTooMuchAutoTimestampCols: 2, + ErTruncatedWrongValue: 2, + ErUdpateTooMuchRows: 1, + ErUnknownCharacterSet: 2, + ErUnknownCharset: 1, + ErUnknownCollation: 1, + ErUnknownSystemVariable: 2, + ErUnknownTable: 2, + ErUseEnum: 1, + ErUseIndexVisibility: 2, + ErUseTextOrBlob: 2, + ErUseValueExpr: 1, + ErUsername: 2, + ErVarcharToTextLen: 2, + ErViewSelectClause: 2, + ErViewSupport: 2, + ErWithDefaultAddColumn: 1, + ErWithInsertField: 1, + ErWithInsertValues: 2, + ErWithLimitCondition: 1, + ErWithOrderbyCondition: 1, + ErWrongAndExpr: 1, + ErWrongArguments: 2, + ErWrongAutoKey: 2, + ErWrongColumnName: 2, + ErWrongDbName: 2, + ErWrongKeyColumn: 2, + ErWrongNameForIndex: 2, + ErWrongStringLength: 2, + ErWrongSubKey: 2, + ErWrongTableName: 2, + ErWrongUsage: 2, + ErWrongValueCountOnRow: 2, + ErWrongValueForVar: 2, +} diff --git a/config/generate_levels/main.go b/config/generate_levels/main.go new file mode 100644 index 000000000..98dad2b82 --- /dev/null +++ b/config/generate_levels/main.go @@ -0,0 +1,67 @@ +package main + +import ( + "os" + "sort" + "text/template" + + "github.com/hanchuanchuan/goInception/session" +) + +type ErrorLevel struct { + OptionName string + Level uint8 + TomlValue string +} + +const tmpl = ` +// Code generated by make level. DO NOT EDIT. + +package config + +type IncLevel2 struct { +{{ range $opt := . }}` + " {{ $opt.OptionName }} uint8 `toml:\"{{ $opt.TomlValue }}\"`" + + ` +{{ end }}} + +var DefaultLevel = IncLevel2 { +{{ range $opt := . }} {{ $opt.OptionName }}: {{ $opt.Level }}, +{{ end }}} +` + +func GenerateLevels() []ErrorLevel { + results := make([]ErrorLevel, 0, len(session.ErrorsDefault)) + for e := range session.ErrorsDefault { + if e <= session.ErrorCode(session.ER_ERROR_FIRST) || + e >= session.ErrorCode(session.ER_ERROR_LAST) { + continue + } + name := e.String() + if name == "" { + continue + } + results = append(results, ErrorLevel{ + OptionName: session.ToCamel(name), + Level: session.GetErrorLevel(e), + TomlValue: name, + }) + } + sort.SliceStable(results, func(i, j int) bool { + return results[i].TomlValue < results[j].TomlValue + }) + return results +} + +func main() { + t := template.Must(template.New("tmpl").Parse(tmpl)) + file, err := os.OpenFile("config/error_level2.go", os.O_TRUNC|os.O_RDWR|os.O_CREATE, 0600) + if err != nil { + panic(err) + } + defer file.Close() + err = t.Execute(file, GenerateLevels()) + if err != nil { + panic(err) + } + +} diff --git a/go.mod b/go.mod index 1459d3aa8..e97e895a6 100644 --- a/go.mod +++ b/go.mod @@ -49,10 +49,10 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.5.1 // indirect github.com/hanchuanchuan/gh-ost v1.0.49-0.20210117111015-ca873c0b5ca6 github.com/hanchuanchuan/go-mysql v0.0.0-20200114082439-6d0d8d3a982e + github.com/hanchuanchuan/inception-core v1.0.0 github.com/imroc/req v0.2.3 github.com/jinzhu/copier v0.3.5 github.com/jinzhu/gorm v1.9.2 - github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect github.com/jinzhu/now v0.0.0-20181116074157-8ec929ed50c3 // indirect github.com/jonboulle/clockwork v0.1.0 // indirect github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 @@ -90,8 +90,6 @@ require ( github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 // indirect github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d // indirect github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect - go.uber.org/atomic v1.3.2 // indirect - go.uber.org/multierr v1.1.0 // indirect go.uber.org/zap v1.9.1 // indirect golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 golang.org/x/text v0.3.2 diff --git a/go.sum b/go.sum index a6c299cda..2db678acf 100644 --- a/go.sum +++ b/go.sum @@ -77,6 +77,7 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCy github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= @@ -91,12 +92,15 @@ github.com/grpc-ecosystem/grpc-gateway v1.5.1 h1:3scN4iuXkNOyP98jF55Lv8a9j1o/Iwv github.com/grpc-ecosystem/grpc-gateway v1.5.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hanchuanchuan/gcfg.v1 v0.0.0-20190302111942-77c0f3dcc0b3 h1:PerDKRFKMglE4GRVZ34aS7pua67+Ht7hIPVVoSSUk2w= github.com/hanchuanchuan/gcfg.v1 v0.0.0-20190302111942-77c0f3dcc0b3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +github.com/hanchuanchuan/gh-ost v1.0.49-0.20200114083508-62a578b91654/go.mod h1:9NockcUOKVL+JLrnCsXtpRAuPseKoMVqfDmn251PbG0= github.com/hanchuanchuan/gh-ost v1.0.49-0.20210117111015-ca873c0b5ca6 h1:Y+HuCqPvpZIS6ekyPxQZbYnzaYhPED/TnvnK9GXox3c= github.com/hanchuanchuan/gh-ost v1.0.49-0.20210117111015-ca873c0b5ca6/go.mod h1:9NockcUOKVL+JLrnCsXtpRAuPseKoMVqfDmn251PbG0= github.com/hanchuanchuan/go-mysql v0.0.0-20200114082439-6d0d8d3a982e h1:IjLlaPxsWKkYuePu8Ed2YbHLuBAuKLW6lclhmeq2A6I= github.com/hanchuanchuan/go-mysql v0.0.0-20200114082439-6d0d8d3a982e/go.mod h1:HJV3Ej7p/Ck/htb5F5VwYAHDL02jA4J6uAufArtmsos= github.com/hanchuanchuan/golib v0.0.0-20200113085747-47643bc243f1 h1:h4yTn7Lu9roQdSZezhf8BwMi3R/KWikL6xV02rmZj6Q= github.com/hanchuanchuan/golib v0.0.0-20200113085747-47643bc243f1/go.mod h1:6V4x6V71pCU4o9UfPmemdrU9sEhSF6AmXt+PiFr8x4Q= +github.com/hanchuanchuan/inception-core v1.0.0 h1:uDEpZYNS1w6qhuOQ4N5fGV9HpdCFOoapmoyTpnwFCps= +github.com/hanchuanchuan/inception-core v1.0.0/go.mod h1:+WHiKS93/xp5Jx0k9h/I0mXoqk7XZ+yaUKThG1BXZG0= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= @@ -109,6 +113,8 @@ github.com/jinzhu/gorm v1.9.2 h1:lCvgEaqe/HVE+tjAR2mt4HbbHAZsQOv3XAZiEZV37iw= github.com/jinzhu/gorm v1.9.2/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo= github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a h1:eeaG9XMUvRBYXJi4pg1ZKM7nxc5AfXfojeLLW7O5J3k= github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v0.0.0-20181116074157-8ec929ed50c3 h1:xvj06l8iSwiWpYgm8MbPp+naBg+pwfqmdXabzqPCn/8= github.com/jinzhu/now v0.0.0-20181116074157-8ec929ed50c3/go.mod h1:oHTiXerJ20+SfYcrdlBO7rzZRJWGwSTQ0iUY2jI6Gfc= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= @@ -125,6 +131,7 @@ github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDK github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -189,6 +196,7 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d h1:GoAlyOgbOEIFd github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 h1:/NRJ5vAYoqz+7sG51ubIDHXeWO8DlTSrToPu6q11ziA= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE= @@ -217,6 +225,7 @@ github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc= @@ -232,24 +241,33 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200109152110-61a87790db17 h1:nVJ3guKA9qdkEQ3TUdXI9QSINo2CUPM/cySEvw2w8I0= golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -267,6 +285,11 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181008205924-a2b3f7f249e9/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -276,8 +299,10 @@ google.golang.org/grpc v0.0.0-20180607172857-7a6a684ca69e/go.mod h1:yo6s7OP7yaDg google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= @@ -290,3 +315,4 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/session/camel.go b/session/camel.go new file mode 100644 index 000000000..840d8c1a1 --- /dev/null +++ b/session/camel.go @@ -0,0 +1,86 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ian Coleman + * Copyright (c) 2018 Ma_124, + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, Subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or Substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// refrences https://github.com/iancoleman/strcase/blob/master/camel.go + +package session + +import ( + "strings" +) + +var uppercaseAcronym = map[string]string{ + "ID": "id", +} + +// Converts a string to CamelCase +func toCamelInitCase(s string, initCase bool) string { + s = strings.TrimSpace(s) + if s == "" { + return s + } + if a, ok := uppercaseAcronym[s]; ok { + s = a + } + + n := strings.Builder{} + n.Grow(len(s)) + capNext := initCase + for i, v := range []byte(s) { + vIsCap := v >= 'A' && v <= 'Z' + vIsLow := v >= 'a' && v <= 'z' + if capNext { + if vIsLow { + v += 'A' + v -= 'a' + } + } else if i == 0 { + if vIsCap { + v += 'a' + v -= 'A' + } + } + if vIsCap || vIsLow { + n.WriteByte(v) + capNext = false + } else if vIsNum := v >= '0' && v <= '9'; vIsNum { + n.WriteByte(v) + capNext = true + } else { + capNext = v == '_' || v == ' ' || v == '-' || v == '.' + } + } + return n.String() +} + +// ToCamel converts a string to CamelCase +func ToCamel(s string) string { + return toCamelInitCase(s, true) +} + +// ToLowerCamel converts a string to lowerCamelCase +func ToLowerCamel(s string) string { + return toCamelInitCase(s, false) +} diff --git a/session/core.go b/session/core.go index c2af6062b..b14abffb6 100644 --- a/session/core.go +++ b/session/core.go @@ -133,6 +133,7 @@ func (s *session) init() { // 自定义审核级别,通过解析config.GetGlobalConfig().IncLevel生成 s.parseIncLevel() + } // clear 清理变量或map等信息 From d0a590bfafbc9973863cc1a7008b5d16666c4788 Mon Sep 17 00:00:00 2001 From: hanchuanchuan Date: Sun, 12 Jun 2022 20:19:12 +0800 Subject: [PATCH 2/2] update --- Makefile | 1 - config/config.toml.default | 129 ++++++++- config/error_level.go | 306 +++++++++++--------- config/error_level2.go | 353 ----------------------- config/generate_levels/main.go | 24 +- session/errors.go | 218 -------------- session/session_inception.go | 6 +- session/session_inception_common_test.go | 7 +- session/session_inception_exec_test.go | 16 +- session/session_inception_test.go | 27 +- 10 files changed, 337 insertions(+), 750 deletions(-) delete mode 100644 config/error_level2.go diff --git a/Makefile b/Makefile index e579dc0ce..7e5fee377 100644 --- a/Makefile +++ b/Makefile @@ -381,6 +381,5 @@ docs: $(shell bash docs/deploy.sh) level: - @rm -f config/error_level.go $(GO) run config/generate_levels/main.go gofmt -w config/error_level.go diff --git a/config/config.toml.default b/config/config.toml.default index a266a2435..2860831d3 100644 --- a/config/config.toml.default +++ b/config/config.toml.default @@ -115,66 +115,175 @@ max_allowed_packet = 4194304 er_alter_table_once = 1 er_auto_incr_id_warning = 1 er_autoinc_unsigned = 1 +er_bad_field_error = 2 +er_bad_null_error = 2 +er_binlog_corrupted = 2 +er_binlog_format_statement = 2 er_blob_cant_have_default = 1 +er_blob_used_as_key = 2 er_cant_change_column = 1 er_cant_change_column_position = 1 +er_cant_drop_database = 2 +er_cant_drop_field_or_key = 2 +er_cant_drop_table = 2 +er_cant_remove_all_fields = 2 er_cant_set_charset = 1 er_cant_set_collation = 1 er_cant_set_engine = 1 er_change_column_type = 1 er_change_too_much_rows = 1 er_char_to_varchar_len = 1 +er_charset_not_support = 2 er_charset_on_column = 1 +er_collation_charset_mismatch = 2 +er_collation_not_support = 2 +er_column_existed = 2 er_column_have_no_comment = 1 -er_datetime_default = 1 +er_column_not_existed = 2 +er_columns_must_have_index = 1 +er_columns_must_have_index_type_err = 1 +er_con_count_error = 2 +er_conflicting_declarations = 2 +er_data_too_long = 2 +er_db_not_existed_error = 2 +er_ddl_dml_coexist = 2 +er_dup_fieldname = 2 +er_dup_index = 2 +er_dup_keyname = 2 +er_end_with_commit = 2 +er_end_with_semicolon = 2 +er_engine_not_support = 2 +er_error_exist_before = 2 +er_field_not_in_group_by = 2 +er_field_specified_twice = 2 er_float_double_to_decimal = 2 +er_forcing_close = 2 er_foreign_key = 2 +er_have_begin = 2 +er_hostname = 2 +er_id_is_uper = 2 er_ident_use_keyword = 1 +er_identifier_lower = 2 +er_identifier_upper = 2 er_implicit_type_conversion = 1 er_inc_init_err = 1 +er_inception_empty_query = 2 +er_incorrect_datetime_value = 2 +er_incorrect_global_local_var = 2 er_index_name_idx_prefix = 1 er_index_name_uniq_prefix = 1 +er_index_use_alter_table = 2 er_insert_too_much_rows = 1 +er_invalid_backup_host_info = 2 +er_invalid_command = 2 er_invalid_data_type = 1 +er_invalid_default = 2 +er_invalid_group_func_use = 2 er_invalid_ident = 1 -er_mariadb_rollback_warn = 1 +er_invalid_on_update = 2 er_join_no_on_condition = 1 er_json_type_support = 2 +er_key_column_does_not_exits = 2 +er_mariadb_rollback_warn = 1 +er_max_column_count = 1 +er_max_varchar_length = 2 +er_mix_of_group_func_and_fields = 2 +er_multiple_pri_key = 2 +er_must_at_least_one_column = 2 er_must_have_columns = 1 -er_columns_must_have_index = 1 -er_columns_must_have_index_type_err = 1 +er_net_packets_out_of_order = 2 +er_net_read_error = 2 +er_net_read_interrupted = 2 +er_network_read_event_checksum_failure = 2 +er_no_db_error = 2 er_no_where_condition = 1 +er_non_uniq_error = 2 +er_non_uniq_table = 2 +er_normal_shutdown = 2 er_not_allowed_nullable = 1 +er_not_found_master_status = 2 +er_not_found_table_info = 1 +er_not_supported_alter_option = 1 +er_not_supported_item_type = 2 +er_not_supported_key_type = 2 +er_not_supported_yet = 2 +er_not_valid_password = 2 er_ordery_by_rand = 1 +er_osc_kill_failed = 2 +er_outofmemory = 1 +er_parse_error = 2 er_partition_not_allowed = 1 +er_partition_not_existed = 2 er_pk_cols_not_int = 1 er_pk_too_many_parts = 1 +er_primary_cant_have_null = 2 +er_remote_exe_error = 2 +er_removed_spaces = 2 +er_repeat_const_definition = 2 +er_same_name_partition = 2 er_select_only_star = 1 er_set_data_type_int_bigint = 2 +er_shutdown_complete = 2 +er_slave_corrupt_event = 2 +er_slave_relay_log_write_failure = 2 +er_sql_invalid_op_type = 2 +er_sql_invalid_source = 2 +er_sql_no_op_type = 2 +er_sql_no_source = 2 +er_start_as_begin = 2 +er_syntax_error = 2 +er_table_cant_handle_auto_increment = 2 er_table_charset_must_null = 1 er_table_charset_must_utf8 = 1 +er_table_collation_not_support = 1 +er_table_exists_error = 2 er_table_must_have_comment = 1 er_table_must_have_pk = 1 +er_table_not_existed_error = 2 er_table_prefix = 1 +er_temp_table_tmp_prefix = 1 er_text_not_nullable_error = 1 er_timestamp_default = 1 +er_too_long_bakdb_name = 2 +er_too_long_ident = 2 +er_too_long_index_comment = 1 +er_too_long_key = 2 er_too_many_key_parts = 1 er_too_many_keys = 1 -er_too_much_auto_datetime_cols = 2 er_too_much_auto_timestamp_cols = 2 +er_truncated_wrong_value = 2 er_udpate_too_much_rows = 1 +er_unknown_character_set = 2 +er_unknown_charset = 1 +er_unknown_collation = 1 +er_unknown_system_variable = 2 +er_unknown_table = 2 er_use_enum = 1 +er_use_index_visibility = 2 er_use_text_or_blob = 2 +er_use_value_expr = 1 +er_username = 2 +er_varchar_to_text_len = 2 +er_view_select_clause = 2 +er_view_support = 2 er_with_default_add_column = 1 er_with_insert_field = 1 +er_with_insert_values = 2 er_with_limit_condition = 1 er_with_orderby_condition = 1 -er_use_value_expr = 1 er_wrong_and_expr = 1 -er_view_support = 2 -er_incorrect_datetime_value = 2 -er_max_varchar_length = 2 -er_max_column_count = 1 +er_wrong_arguments = 2 +er_wrong_auto_key = 2 +er_wrong_column_name = 2 +er_wrong_db_name = 2 +er_wrong_key_column = 2 +er_wrong_name_for_index = 2 +er_wrong_string_length = 2 +er_wrong_sub_key = 2 +er_wrong_table_name = 2 +er_wrong_usage = 2 +er_wrong_value_count_on_row = 2 +er_wrong_value_for_var = 2 [osc] diff --git a/config/error_level.go b/config/error_level.go index 6a353e03b..c8703dece 100644 --- a/config/error_level.go +++ b/config/error_level.go @@ -1,73 +1,183 @@ +// Code generated by make level. DO NOT EDIT. + package config type IncLevel struct { - ER_ALTER_TABLE_ONCE int8 `toml:"er_alter_table_once"` - ER_AUTO_INCR_ID_WARNING int8 `toml:"er_auto_incr_id_warning"` - ER_AUTOINC_UNSIGNED int8 `toml:"er_autoinc_unsigned"` - ER_BLOB_CANT_HAVE_DEFAULT int8 `toml:"er_blob_cant_have_default"` - ER_CANT_SET_CHARSET int8 `toml:"er_cant_set_charset"` - ER_CANT_SET_COLLATION int8 `toml:"er_cant_set_collation"` - ER_CANT_SET_ENGINE int8 `toml:"er_cant_set_engine"` - ER_CHANGE_COLUMN_TYPE int8 `toml:"er_change_column_type"` - ER_CHANGE_TOO_MUCH_ROWS int8 `toml:"er_change_too_much_rows"` - ER_CHAR_TO_VARCHAR_LEN int8 `toml:"er_char_to_varchar_len"` - ER_CHARSET_ON_COLUMN int8 `toml:"er_charset_on_column"` - ER_COLUMN_HAVE_NO_COMMENT int8 `toml:"er_column_have_no_comment"` - ER_DATETIME_DEFAULT int8 `toml:"er_datetime_default"` - ErrFloatDoubleToDecimal int8 `toml:"er_float_double_to_decimal"` - ER_FOREIGN_KEY int8 `toml:"er_foreign_key"` - ER_IDENT_USE_KEYWORD int8 `toml:"er_ident_use_keyword"` - ER_INC_INIT_ERR int8 `toml:"er_inc_init_err"` - - ER_INDEX_NAME_IDX_PREFIX int8 `toml:"er_index_name_idx_prefix"` - ER_INDEX_NAME_UNIQ_PREFIX int8 `toml:"er_index_name_uniq_prefix"` - ER_INSERT_TOO_MUCH_ROWS int8 `toml:"er_insert_too_much_rows"` - ER_INVALID_DATA_TYPE int8 `toml:"er_invalid_data_type"` - ER_INVALID_IDENT int8 `toml:"er_invalid_ident"` - ErrMariaDBRollbackWarn int8 `toml:"er_mariadb_rollback_warn"` - ER_MUST_HAVE_COLUMNS int8 `toml:"er_must_have_columns"` - ErrColumnsMustHaveIndex int8 `toml:"er_columns_must_have_index"` - ErrColumnsMustHaveIndexTypeErr int8 `toml:"er_columns_must_have_index_type_err"` - ER_NO_WHERE_CONDITION int8 `toml:"er_no_where_condition"` - ER_NOT_ALLOWED_NULLABLE int8 `toml:"er_not_allowed_nullable"` - ER_ORDERY_BY_RAND int8 `toml:"er_ordery_by_rand"` - ER_PARTITION_NOT_ALLOWED int8 `toml:"er_partition_not_allowed"` - ER_PK_COLS_NOT_INT int8 `toml:"er_pk_cols_not_int"` - ER_PK_TOO_MANY_PARTS int8 `toml:"er_pk_too_many_parts"` - ER_SELECT_ONLY_STAR int8 `toml:"er_select_only_star"` - ER_SET_DATA_TYPE_INT_BIGINT int8 `toml:"er_set_data_type_int_bigint"` - ER_TABLE_CHARSET_MUST_NULL int8 `toml:"er_table_charset_must_null"` - ER_TABLE_CHARSET_MUST_UTF8 int8 `toml:"er_table_charset_must_utf8"` - ER_TABLE_MUST_HAVE_COMMENT int8 `toml:"er_table_must_have_comment"` - ER_TABLE_MUST_HAVE_PK int8 `toml:"er_table_must_have_pk"` - ER_TABLE_PREFIX int8 `toml:"er_table_prefix"` - ER_TEXT_NOT_NULLABLE_ERROR int8 `toml:"er_text_not_nullable_error"` - ER_TIMESTAMP_DEFAULT int8 `toml:"er_timestamp_default"` - ER_TOO_MANY_KEY_PARTS int8 `toml:"er_too_many_key_parts"` - ER_TOO_MANY_KEYS int8 `toml:"er_too_many_keys"` - ER_TOO_MUCH_AUTO_DATETIME_COLS int8 `toml:"er_too_much_auto_datetime_cols"` - ER_TOO_MUCH_AUTO_TIMESTAMP_COLS int8 `toml:"er_too_much_auto_timestamp_cols"` - ER_UDPATE_TOO_MUCH_ROWS int8 `toml:"er_udpate_too_much_rows"` - ER_USE_ENUM int8 `toml:"er_use_enum"` - ER_USE_TEXT_OR_BLOB int8 `toml:"er_use_text_or_blob"` - ER_WITH_DEFAULT_ADD_COLUMN int8 `toml:"er_with_default_add_column"` - ER_WITH_INSERT_FIELD int8 `toml:"er_with_insert_field"` - ER_WITH_LIMIT_CONDITION int8 `toml:"er_with_limit_condition"` - ER_WITH_ORDERBY_CONDITION int8 `toml:"er_with_orderby_condition"` - ErCantChangeColumn int8 `toml:"er_cant_change_column"` - ErCantChangeColumnPosition int8 `toml:"er_cant_change_column_position"` - ErJsonTypeSupport int8 `toml:"er_json_type_support"` - ErrImplicitTypeConversion int8 `toml:"er_implicit_type_conversion"` - ErrJoinNoOnCondition int8 `toml:"er_join_no_on_condition"` - ErrUseValueExpr int8 `toml:"er_use_value_expr"` - ErrWrongAndExpr int8 `toml:"er_wrong_and_expr"` - ErrViewSupport int8 `toml:"er_view_support"` - ErrIncorrectDateTimeValue int8 `toml:"er_incorrect_datetime_value"` - ErrMaxVarcharLength int8 `toml:"er_max_varchar_length"` - ErrMaxColumnCount int8 `toml:"er_max_column_count"` + ErAlterTableOnce uint8 `toml:"er_alter_table_once"` + ErAutoIncrIdWarning uint8 `toml:"er_auto_incr_id_warning"` + ErAutoincUnsigned uint8 `toml:"er_autoinc_unsigned"` + ErBadFieldError uint8 `toml:"er_bad_field_error"` + ErBadNullError uint8 `toml:"er_bad_null_error"` + ErBinlogCorrupted uint8 `toml:"er_binlog_corrupted"` + ErBinlogFormatStatement uint8 `toml:"er_binlog_format_statement"` + ErBlobCantHaveDefault uint8 `toml:"er_blob_cant_have_default"` + ErBlobUsedAsKey uint8 `toml:"er_blob_used_as_key"` + ErCantChangeColumn uint8 `toml:"er_cant_change_column"` + ErCantChangeColumnPosition uint8 `toml:"er_cant_change_column_position"` + ErCantDropDatabase uint8 `toml:"er_cant_drop_database"` + ErCantDropFieldOrKey uint8 `toml:"er_cant_drop_field_or_key"` + ErCantDropTable uint8 `toml:"er_cant_drop_table"` + ErCantRemoveAllFields uint8 `toml:"er_cant_remove_all_fields"` + ErCantSetCharset uint8 `toml:"er_cant_set_charset"` + ErCantSetCollation uint8 `toml:"er_cant_set_collation"` + ErCantSetEngine uint8 `toml:"er_cant_set_engine"` + ErChangeColumnType uint8 `toml:"er_change_column_type"` + ErChangeTooMuchRows uint8 `toml:"er_change_too_much_rows"` + ErCharToVarcharLen uint8 `toml:"er_char_to_varchar_len"` + ErCharsetNotSupport uint8 `toml:"er_charset_not_support"` + ErCharsetOnColumn uint8 `toml:"er_charset_on_column"` + ErCollationCharsetMismatch uint8 `toml:"er_collation_charset_mismatch"` + ErCollationNotSupport uint8 `toml:"er_collation_not_support"` + ErColumnExisted uint8 `toml:"er_column_existed"` + ErColumnHaveNoComment uint8 `toml:"er_column_have_no_comment"` + ErColumnNotExisted uint8 `toml:"er_column_not_existed"` + ErColumnsMustHaveIndex uint8 `toml:"er_columns_must_have_index"` + ErColumnsMustHaveIndexTypeErr uint8 `toml:"er_columns_must_have_index_type_err"` + ErConCountError uint8 `toml:"er_con_count_error"` + ErConflictingDeclarations uint8 `toml:"er_conflicting_declarations"` + ErDataTooLong uint8 `toml:"er_data_too_long"` + ErDbNotExistedError uint8 `toml:"er_db_not_existed_error"` + ErDdlDmlCoexist uint8 `toml:"er_ddl_dml_coexist"` + ErDupFieldname uint8 `toml:"er_dup_fieldname"` + ErDupIndex uint8 `toml:"er_dup_index"` + ErDupKeyname uint8 `toml:"er_dup_keyname"` + ErEndWithCommit uint8 `toml:"er_end_with_commit"` + ErEndWithSemicolon uint8 `toml:"er_end_with_semicolon"` + ErEngineNotSupport uint8 `toml:"er_engine_not_support"` + ErErrorExistBefore uint8 `toml:"er_error_exist_before"` + ErFieldNotInGroupBy uint8 `toml:"er_field_not_in_group_by"` + ErFieldSpecifiedTwice uint8 `toml:"er_field_specified_twice"` + ErFloatDoubleToDecimal uint8 `toml:"er_float_double_to_decimal"` + ErForcingClose uint8 `toml:"er_forcing_close"` + ErForeignKey uint8 `toml:"er_foreign_key"` + ErHaveBegin uint8 `toml:"er_have_begin"` + ErHostname uint8 `toml:"er_hostname"` + ErIdIsUper uint8 `toml:"er_id_is_uper"` + ErIdentUseKeyword uint8 `toml:"er_ident_use_keyword"` + ErIdentifierLower uint8 `toml:"er_identifier_lower"` + ErIdentifierUpper uint8 `toml:"er_identifier_upper"` + ErImplicitTypeConversion uint8 `toml:"er_implicit_type_conversion"` + ErIncInitErr uint8 `toml:"er_inc_init_err"` + ErInceptionEmptyQuery uint8 `toml:"er_inception_empty_query"` + ErIncorrectDatetimeValue uint8 `toml:"er_incorrect_datetime_value"` + ErIncorrectGlobalLocalVar uint8 `toml:"er_incorrect_global_local_var"` + ErIndexNameIdxPrefix uint8 `toml:"er_index_name_idx_prefix"` + ErIndexNameUniqPrefix uint8 `toml:"er_index_name_uniq_prefix"` + ErIndexUseAlterTable uint8 `toml:"er_index_use_alter_table"` + ErInsertTooMuchRows uint8 `toml:"er_insert_too_much_rows"` + ErInvalidBackupHostInfo uint8 `toml:"er_invalid_backup_host_info"` + ErInvalidCommand uint8 `toml:"er_invalid_command"` + ErInvalidDataType uint8 `toml:"er_invalid_data_type"` + ErInvalidDefault uint8 `toml:"er_invalid_default"` + ErInvalidGroupFuncUse uint8 `toml:"er_invalid_group_func_use"` + ErInvalidIdent uint8 `toml:"er_invalid_ident"` + ErInvalidOnUpdate uint8 `toml:"er_invalid_on_update"` + ErJoinNoOnCondition uint8 `toml:"er_join_no_on_condition"` + ErJsonTypeSupport uint8 `toml:"er_json_type_support"` + ErKeyColumnDoesNotExits uint8 `toml:"er_key_column_does_not_exits"` + ErMariadbRollbackWarn uint8 `toml:"er_mariadb_rollback_warn"` + ErMaxColumnCount uint8 `toml:"er_max_column_count"` + ErMaxVarcharLength uint8 `toml:"er_max_varchar_length"` + ErMixOfGroupFuncAndFields uint8 `toml:"er_mix_of_group_func_and_fields"` + ErMultiplePriKey uint8 `toml:"er_multiple_pri_key"` + ErMustAtLeastOneColumn uint8 `toml:"er_must_at_least_one_column"` + ErMustHaveColumns uint8 `toml:"er_must_have_columns"` + ErNetPacketsOutOfOrder uint8 `toml:"er_net_packets_out_of_order"` + ErNetReadError uint8 `toml:"er_net_read_error"` + ErNetReadInterrupted uint8 `toml:"er_net_read_interrupted"` + ErNetworkReadEventChecksumFailure uint8 `toml:"er_network_read_event_checksum_failure"` + ErNoDbError uint8 `toml:"er_no_db_error"` + ErNoWhereCondition uint8 `toml:"er_no_where_condition"` + ErNonUniqError uint8 `toml:"er_non_uniq_error"` + ErNonUniqTable uint8 `toml:"er_non_uniq_table"` + ErNormalShutdown uint8 `toml:"er_normal_shutdown"` + ErNotAllowedNullable uint8 `toml:"er_not_allowed_nullable"` + ErNotFoundMasterStatus uint8 `toml:"er_not_found_master_status"` + ErNotFoundTableInfo uint8 `toml:"er_not_found_table_info"` + ErNotSupportedAlterOption uint8 `toml:"er_not_supported_alter_option"` + ErNotSupportedItemType uint8 `toml:"er_not_supported_item_type"` + ErNotSupportedKeyType uint8 `toml:"er_not_supported_key_type"` + ErNotSupportedYet uint8 `toml:"er_not_supported_yet"` + ErNotValidPassword uint8 `toml:"er_not_valid_password"` + ErOrderyByRand uint8 `toml:"er_ordery_by_rand"` + ErOscKillFailed uint8 `toml:"er_osc_kill_failed"` + ErOutofmemory uint8 `toml:"er_outofmemory"` + ErParseError uint8 `toml:"er_parse_error"` + ErPartitionNotAllowed uint8 `toml:"er_partition_not_allowed"` + ErPartitionNotExisted uint8 `toml:"er_partition_not_existed"` + ErPkColsNotInt uint8 `toml:"er_pk_cols_not_int"` + ErPkTooManyParts uint8 `toml:"er_pk_too_many_parts"` + ErPrimaryCantHaveNull uint8 `toml:"er_primary_cant_have_null"` + ErRemoteExeError uint8 `toml:"er_remote_exe_error"` + ErRemovedSpaces uint8 `toml:"er_removed_spaces"` + ErRepeatConstDefinition uint8 `toml:"er_repeat_const_definition"` + ErSameNamePartition uint8 `toml:"er_same_name_partition"` + ErSelectOnlyStar uint8 `toml:"er_select_only_star"` + ErSetDataTypeIntBigint uint8 `toml:"er_set_data_type_int_bigint"` + ErShutdownComplete uint8 `toml:"er_shutdown_complete"` + ErSlaveCorruptEvent uint8 `toml:"er_slave_corrupt_event"` + ErSlaveRelayLogWriteFailure uint8 `toml:"er_slave_relay_log_write_failure"` + ErSqlInvalidOpType uint8 `toml:"er_sql_invalid_op_type"` + ErSqlInvalidSource uint8 `toml:"er_sql_invalid_source"` + ErSqlNoOpType uint8 `toml:"er_sql_no_op_type"` + ErSqlNoSource uint8 `toml:"er_sql_no_source"` + ErStartAsBegin uint8 `toml:"er_start_as_begin"` + ErSyntaxError uint8 `toml:"er_syntax_error"` + ErTableCantHandleAutoIncrement uint8 `toml:"er_table_cant_handle_auto_increment"` + ErTableCharsetMustNull uint8 `toml:"er_table_charset_must_null"` + ErTableCharsetMustUtf8 uint8 `toml:"er_table_charset_must_utf8"` + ErTableCollationNotSupport uint8 `toml:"er_table_collation_not_support"` + ErTableExistsError uint8 `toml:"er_table_exists_error"` + ErTableMustHaveComment uint8 `toml:"er_table_must_have_comment"` + ErTableMustHavePk uint8 `toml:"er_table_must_have_pk"` + ErTableNotExistedError uint8 `toml:"er_table_not_existed_error"` + ErTablePrefix uint8 `toml:"er_table_prefix"` + ErTempTableTmpPrefix uint8 `toml:"er_temp_table_tmp_prefix"` + ErTextNotNullableError uint8 `toml:"er_text_not_nullable_error"` + ErTimestampDefault uint8 `toml:"er_timestamp_default"` + ErTooLongBakdbName uint8 `toml:"er_too_long_bakdb_name"` + ErTooLongIdent uint8 `toml:"er_too_long_ident"` + ErTooLongIndexComment uint8 `toml:"er_too_long_index_comment"` + ErTooLongKey uint8 `toml:"er_too_long_key"` + ErTooManyKeyParts uint8 `toml:"er_too_many_key_parts"` + ErTooManyKeys uint8 `toml:"er_too_many_keys"` + ErTooMuchAutoTimestampCols uint8 `toml:"er_too_much_auto_timestamp_cols"` + ErTruncatedWrongValue uint8 `toml:"er_truncated_wrong_value"` + ErUdpateTooMuchRows uint8 `toml:"er_udpate_too_much_rows"` + ErUnknownCharacterSet uint8 `toml:"er_unknown_character_set"` + ErUnknownCharset uint8 `toml:"er_unknown_charset"` + ErUnknownCollation uint8 `toml:"er_unknown_collation"` + ErUnknownSystemVariable uint8 `toml:"er_unknown_system_variable"` + ErUnknownTable uint8 `toml:"er_unknown_table"` + ErUseEnum uint8 `toml:"er_use_enum"` + ErUseIndexVisibility uint8 `toml:"er_use_index_visibility"` + ErUseTextOrBlob uint8 `toml:"er_use_text_or_blob"` + ErUseValueExpr uint8 `toml:"er_use_value_expr"` + ErUsername uint8 `toml:"er_username"` + ErVarcharToTextLen uint8 `toml:"er_varchar_to_text_len"` + ErViewSelectClause uint8 `toml:"er_view_select_clause"` + ErViewSupport uint8 `toml:"er_view_support"` + ErWithDefaultAddColumn uint8 `toml:"er_with_default_add_column"` + ErWithInsertField uint8 `toml:"er_with_insert_field"` + ErWithInsertValues uint8 `toml:"er_with_insert_values"` + ErWithLimitCondition uint8 `toml:"er_with_limit_condition"` + ErWithOrderbyCondition uint8 `toml:"er_with_orderby_condition"` + ErWrongAndExpr uint8 `toml:"er_wrong_and_expr"` + ErWrongArguments uint8 `toml:"er_wrong_arguments"` + ErWrongAutoKey uint8 `toml:"er_wrong_auto_key"` + ErWrongColumnName uint8 `toml:"er_wrong_column_name"` + ErWrongDbName uint8 `toml:"er_wrong_db_name"` + ErWrongKeyColumn uint8 `toml:"er_wrong_key_column"` + ErWrongNameForIndex uint8 `toml:"er_wrong_name_for_index"` + ErWrongStringLength uint8 `toml:"er_wrong_string_length"` + ErWrongSubKey uint8 `toml:"er_wrong_sub_key"` + ErWrongTableName uint8 `toml:"er_wrong_table_name"` + ErWrongUsage uint8 `toml:"er_wrong_usage"` + ErWrongValueCountOnRow uint8 `toml:"er_wrong_value_count_on_row"` + ErWrongValueForVar uint8 `toml:"er_wrong_value_for_var"` } -var DefaultLevel = IncLevel2{ +var defaultLevel = IncLevel{ ErAlterTableOnce: 1, ErAutoIncrIdWarning: 1, ErAutoincUnsigned: 1, @@ -241,69 +351,3 @@ var DefaultLevel = IncLevel2{ ErWrongValueCountOnRow: 2, ErWrongValueForVar: 2, } - -var defaultLevel = IncLevel{ - ER_ALTER_TABLE_ONCE: 1, - ER_AUTO_INCR_ID_WARNING: 1, - ER_AUTOINC_UNSIGNED: 1, - ER_BLOB_CANT_HAVE_DEFAULT: 1, - ER_CANT_SET_CHARSET: 1, - ER_CANT_SET_COLLATION: 1, - ER_CANT_SET_ENGINE: 1, - ER_CHANGE_COLUMN_TYPE: 1, - ER_CHANGE_TOO_MUCH_ROWS: 1, - ER_CHAR_TO_VARCHAR_LEN: 1, - ER_CHARSET_ON_COLUMN: 1, - ER_COLUMN_HAVE_NO_COMMENT: 1, - ER_DATETIME_DEFAULT: 1, - ErrFloatDoubleToDecimal: 2, - ER_FOREIGN_KEY: 2, - ER_IDENT_USE_KEYWORD: 1, - ER_INC_INIT_ERR: 1, - ER_INDEX_NAME_IDX_PREFIX: 1, - ER_INDEX_NAME_UNIQ_PREFIX: 1, - ER_INSERT_TOO_MUCH_ROWS: 1, - ER_INVALID_DATA_TYPE: 1, - ER_INVALID_IDENT: 1, - ErrMariaDBRollbackWarn: 1, - ER_MUST_HAVE_COLUMNS: 1, - ErrColumnsMustHaveIndex: 1, - ErrColumnsMustHaveIndexTypeErr: 1, - ER_NO_WHERE_CONDITION: 1, - ER_NOT_ALLOWED_NULLABLE: 1, - ER_ORDERY_BY_RAND: 1, - ER_PARTITION_NOT_ALLOWED: 1, - ER_PK_COLS_NOT_INT: 1, - ER_PK_TOO_MANY_PARTS: 1, - ER_SELECT_ONLY_STAR: 1, - ER_SET_DATA_TYPE_INT_BIGINT: 2, - ER_TABLE_CHARSET_MUST_NULL: 1, - ER_TABLE_CHARSET_MUST_UTF8: 1, - ER_TABLE_MUST_HAVE_COMMENT: 1, - ER_TABLE_MUST_HAVE_PK: 1, - ER_TABLE_PREFIX: 1, - ER_TEXT_NOT_NULLABLE_ERROR: 1, - ER_TIMESTAMP_DEFAULT: 1, - ER_TOO_MANY_KEY_PARTS: 1, - ER_TOO_MANY_KEYS: 1, - ER_TOO_MUCH_AUTO_DATETIME_COLS: 2, - ER_TOO_MUCH_AUTO_TIMESTAMP_COLS: 2, - ER_UDPATE_TOO_MUCH_ROWS: 1, - ER_USE_ENUM: 1, - ER_USE_TEXT_OR_BLOB: 2, - ER_WITH_DEFAULT_ADD_COLUMN: 1, - ER_WITH_INSERT_FIELD: 1, - ER_WITH_LIMIT_CONDITION: 1, - ER_WITH_ORDERBY_CONDITION: 1, - ErCantChangeColumn: 1, - ErCantChangeColumnPosition: 1, - ErJsonTypeSupport: 2, - ErrImplicitTypeConversion: 1, - ErrJoinNoOnCondition: 1, - ErrUseValueExpr: 1, - ErrWrongAndExpr: 1, - ErrViewSupport: 2, - ErrIncorrectDateTimeValue: 2, - ErrMaxVarcharLength: 2, - ErrMaxColumnCount: 1, -} diff --git a/config/error_level2.go b/config/error_level2.go deleted file mode 100644 index 4573a7ed3..000000000 --- a/config/error_level2.go +++ /dev/null @@ -1,353 +0,0 @@ -// Code generated by make level. DO NOT EDIT. - -package config - -type IncLevel2 struct { - ErAlterTableOnce uint8 `toml:"er_alter_table_once"` - ErAutoIncrIdWarning uint8 `toml:"er_auto_incr_id_warning"` - ErAutoincUnsigned uint8 `toml:"er_autoinc_unsigned"` - ErBadFieldError uint8 `toml:"er_bad_field_error"` - ErBadNullError uint8 `toml:"er_bad_null_error"` - ErBinlogCorrupted uint8 `toml:"er_binlog_corrupted"` - ErBinlogFormatStatement uint8 `toml:"er_binlog_format_statement"` - ErBlobCantHaveDefault uint8 `toml:"er_blob_cant_have_default"` - ErBlobUsedAsKey uint8 `toml:"er_blob_used_as_key"` - ErCantChangeColumn uint8 `toml:"er_cant_change_column"` - ErCantChangeColumnPosition uint8 `toml:"er_cant_change_column_position"` - ErCantDropDatabase uint8 `toml:"er_cant_drop_database"` - ErCantDropFieldOrKey uint8 `toml:"er_cant_drop_field_or_key"` - ErCantDropTable uint8 `toml:"er_cant_drop_table"` - ErCantRemoveAllFields uint8 `toml:"er_cant_remove_all_fields"` - ErCantSetCharset uint8 `toml:"er_cant_set_charset"` - ErCantSetCollation uint8 `toml:"er_cant_set_collation"` - ErCantSetEngine uint8 `toml:"er_cant_set_engine"` - ErChangeColumnType uint8 `toml:"er_change_column_type"` - ErChangeTooMuchRows uint8 `toml:"er_change_too_much_rows"` - ErCharToVarcharLen uint8 `toml:"er_char_to_varchar_len"` - ErCharsetNotSupport uint8 `toml:"er_charset_not_support"` - ErCharsetOnColumn uint8 `toml:"er_charset_on_column"` - ErCollationCharsetMismatch uint8 `toml:"er_collation_charset_mismatch"` - ErCollationNotSupport uint8 `toml:"er_collation_not_support"` - ErColumnExisted uint8 `toml:"er_column_existed"` - ErColumnHaveNoComment uint8 `toml:"er_column_have_no_comment"` - ErColumnNotExisted uint8 `toml:"er_column_not_existed"` - ErColumnsMustHaveIndex uint8 `toml:"er_columns_must_have_index"` - ErColumnsMustHaveIndexTypeErr uint8 `toml:"er_columns_must_have_index_type_err"` - ErConCountError uint8 `toml:"er_con_count_error"` - ErConflictingDeclarations uint8 `toml:"er_conflicting_declarations"` - ErDataTooLong uint8 `toml:"er_data_too_long"` - ErDbNotExistedError uint8 `toml:"er_db_not_existed_error"` - ErDdlDmlCoexist uint8 `toml:"er_ddl_dml_coexist"` - ErDupFieldname uint8 `toml:"er_dup_fieldname"` - ErDupIndex uint8 `toml:"er_dup_index"` - ErDupKeyname uint8 `toml:"er_dup_keyname"` - ErEndWithCommit uint8 `toml:"er_end_with_commit"` - ErEndWithSemicolon uint8 `toml:"er_end_with_semicolon"` - ErEngineNotSupport uint8 `toml:"er_engine_not_support"` - ErErrorExistBefore uint8 `toml:"er_error_exist_before"` - ErFieldNotInGroupBy uint8 `toml:"er_field_not_in_group_by"` - ErFieldSpecifiedTwice uint8 `toml:"er_field_specified_twice"` - ErFloatDoubleToDecimal uint8 `toml:"er_float_double_to_decimal"` - ErForcingClose uint8 `toml:"er_forcing_close"` - ErForeignKey uint8 `toml:"er_foreign_key"` - ErHaveBegin uint8 `toml:"er_have_begin"` - ErHostname uint8 `toml:"er_hostname"` - ErIdIsUper uint8 `toml:"er_id_is_uper"` - ErIdentUseKeyword uint8 `toml:"er_ident_use_keyword"` - ErIdentifierLower uint8 `toml:"er_identifier_lower"` - ErIdentifierUpper uint8 `toml:"er_identifier_upper"` - ErImplicitTypeConversion uint8 `toml:"er_implicit_type_conversion"` - ErIncInitErr uint8 `toml:"er_inc_init_err"` - ErInceptionEmptyQuery uint8 `toml:"er_inception_empty_query"` - ErIncorrectDatetimeValue uint8 `toml:"er_incorrect_datetime_value"` - ErIncorrectGlobalLocalVar uint8 `toml:"er_incorrect_global_local_var"` - ErIndexNameIdxPrefix uint8 `toml:"er_index_name_idx_prefix"` - ErIndexNameUniqPrefix uint8 `toml:"er_index_name_uniq_prefix"` - ErIndexUseAlterTable uint8 `toml:"er_index_use_alter_table"` - ErInsertTooMuchRows uint8 `toml:"er_insert_too_much_rows"` - ErInvalidBackupHostInfo uint8 `toml:"er_invalid_backup_host_info"` - ErInvalidCommand uint8 `toml:"er_invalid_command"` - ErInvalidDataType uint8 `toml:"er_invalid_data_type"` - ErInvalidDefault uint8 `toml:"er_invalid_default"` - ErInvalidGroupFuncUse uint8 `toml:"er_invalid_group_func_use"` - ErInvalidIdent uint8 `toml:"er_invalid_ident"` - ErInvalidOnUpdate uint8 `toml:"er_invalid_on_update"` - ErJoinNoOnCondition uint8 `toml:"er_join_no_on_condition"` - ErJsonTypeSupport uint8 `toml:"er_json_type_support"` - ErKeyColumnDoesNotExits uint8 `toml:"er_key_column_does_not_exits"` - ErMariadbRollbackWarn uint8 `toml:"er_mariadb_rollback_warn"` - ErMaxColumnCount uint8 `toml:"er_max_column_count"` - ErMaxVarcharLength uint8 `toml:"er_max_varchar_length"` - ErMixOfGroupFuncAndFields uint8 `toml:"er_mix_of_group_func_and_fields"` - ErMultiplePriKey uint8 `toml:"er_multiple_pri_key"` - ErMustAtLeastOneColumn uint8 `toml:"er_must_at_least_one_column"` - ErMustHaveColumns uint8 `toml:"er_must_have_columns"` - ErNetPacketsOutOfOrder uint8 `toml:"er_net_packets_out_of_order"` - ErNetReadError uint8 `toml:"er_net_read_error"` - ErNetReadInterrupted uint8 `toml:"er_net_read_interrupted"` - ErNetworkReadEventChecksumFailure uint8 `toml:"er_network_read_event_checksum_failure"` - ErNoDbError uint8 `toml:"er_no_db_error"` - ErNoWhereCondition uint8 `toml:"er_no_where_condition"` - ErNonUniqError uint8 `toml:"er_non_uniq_error"` - ErNonUniqTable uint8 `toml:"er_non_uniq_table"` - ErNormalShutdown uint8 `toml:"er_normal_shutdown"` - ErNotAllowedNullable uint8 `toml:"er_not_allowed_nullable"` - ErNotFoundMasterStatus uint8 `toml:"er_not_found_master_status"` - ErNotFoundTableInfo uint8 `toml:"er_not_found_table_info"` - ErNotSupportedAlterOption uint8 `toml:"er_not_supported_alter_option"` - ErNotSupportedItemType uint8 `toml:"er_not_supported_item_type"` - ErNotSupportedKeyType uint8 `toml:"er_not_supported_key_type"` - ErNotSupportedYet uint8 `toml:"er_not_supported_yet"` - ErNotValidPassword uint8 `toml:"er_not_valid_password"` - ErOrderyByRand uint8 `toml:"er_ordery_by_rand"` - ErOscKillFailed uint8 `toml:"er_osc_kill_failed"` - ErOutofmemory uint8 `toml:"er_outofmemory"` - ErParseError uint8 `toml:"er_parse_error"` - ErPartitionNotAllowed uint8 `toml:"er_partition_not_allowed"` - ErPartitionNotExisted uint8 `toml:"er_partition_not_existed"` - ErPkColsNotInt uint8 `toml:"er_pk_cols_not_int"` - ErPkTooManyParts uint8 `toml:"er_pk_too_many_parts"` - ErPrimaryCantHaveNull uint8 `toml:"er_primary_cant_have_null"` - ErRemoteExeError uint8 `toml:"er_remote_exe_error"` - ErRemovedSpaces uint8 `toml:"er_removed_spaces"` - ErRepeatConstDefinition uint8 `toml:"er_repeat_const_definition"` - ErSameNamePartition uint8 `toml:"er_same_name_partition"` - ErSelectOnlyStar uint8 `toml:"er_select_only_star"` - ErSetDataTypeIntBigint uint8 `toml:"er_set_data_type_int_bigint"` - ErShutdownComplete uint8 `toml:"er_shutdown_complete"` - ErSlaveCorruptEvent uint8 `toml:"er_slave_corrupt_event"` - ErSlaveRelayLogWriteFailure uint8 `toml:"er_slave_relay_log_write_failure"` - ErSqlInvalidOpType uint8 `toml:"er_sql_invalid_op_type"` - ErSqlInvalidSource uint8 `toml:"er_sql_invalid_source"` - ErSqlNoOpType uint8 `toml:"er_sql_no_op_type"` - ErSqlNoSource uint8 `toml:"er_sql_no_source"` - ErStartAsBegin uint8 `toml:"er_start_as_begin"` - ErSyntaxError uint8 `toml:"er_syntax_error"` - ErTableCantHandleAutoIncrement uint8 `toml:"er_table_cant_handle_auto_increment"` - ErTableCharsetMustNull uint8 `toml:"er_table_charset_must_null"` - ErTableCharsetMustUtf8 uint8 `toml:"er_table_charset_must_utf8"` - ErTableCollationNotSupport uint8 `toml:"er_table_collation_not_support"` - ErTableExistsError uint8 `toml:"er_table_exists_error"` - ErTableMustHaveComment uint8 `toml:"er_table_must_have_comment"` - ErTableMustHavePk uint8 `toml:"er_table_must_have_pk"` - ErTableNotExistedError uint8 `toml:"er_table_not_existed_error"` - ErTablePrefix uint8 `toml:"er_table_prefix"` - ErTempTableTmpPrefix uint8 `toml:"er_temp_table_tmp_prefix"` - ErTextNotNullableError uint8 `toml:"er_text_not_nullable_error"` - ErTimestampDefault uint8 `toml:"er_timestamp_default"` - ErTooLongBakdbName uint8 `toml:"er_too_long_bakdb_name"` - ErTooLongIdent uint8 `toml:"er_too_long_ident"` - ErTooLongIndexComment uint8 `toml:"er_too_long_index_comment"` - ErTooLongKey uint8 `toml:"er_too_long_key"` - ErTooManyKeyParts uint8 `toml:"er_too_many_key_parts"` - ErTooManyKeys uint8 `toml:"er_too_many_keys"` - ErTooMuchAutoTimestampCols uint8 `toml:"er_too_much_auto_timestamp_cols"` - ErTruncatedWrongValue uint8 `toml:"er_truncated_wrong_value"` - ErUdpateTooMuchRows uint8 `toml:"er_udpate_too_much_rows"` - ErUnknownCharacterSet uint8 `toml:"er_unknown_character_set"` - ErUnknownCharset uint8 `toml:"er_unknown_charset"` - ErUnknownCollation uint8 `toml:"er_unknown_collation"` - ErUnknownSystemVariable uint8 `toml:"er_unknown_system_variable"` - ErUnknownTable uint8 `toml:"er_unknown_table"` - ErUseEnum uint8 `toml:"er_use_enum"` - ErUseIndexVisibility uint8 `toml:"er_use_index_visibility"` - ErUseTextOrBlob uint8 `toml:"er_use_text_or_blob"` - ErUseValueExpr uint8 `toml:"er_use_value_expr"` - ErUsername uint8 `toml:"er_username"` - ErVarcharToTextLen uint8 `toml:"er_varchar_to_text_len"` - ErViewSelectClause uint8 `toml:"er_view_select_clause"` - ErViewSupport uint8 `toml:"er_view_support"` - ErWithDefaultAddColumn uint8 `toml:"er_with_default_add_column"` - ErWithInsertField uint8 `toml:"er_with_insert_field"` - ErWithInsertValues uint8 `toml:"er_with_insert_values"` - ErWithLimitCondition uint8 `toml:"er_with_limit_condition"` - ErWithOrderbyCondition uint8 `toml:"er_with_orderby_condition"` - ErWrongAndExpr uint8 `toml:"er_wrong_and_expr"` - ErWrongArguments uint8 `toml:"er_wrong_arguments"` - ErWrongAutoKey uint8 `toml:"er_wrong_auto_key"` - ErWrongColumnName uint8 `toml:"er_wrong_column_name"` - ErWrongDbName uint8 `toml:"er_wrong_db_name"` - ErWrongKeyColumn uint8 `toml:"er_wrong_key_column"` - ErWrongNameForIndex uint8 `toml:"er_wrong_name_for_index"` - ErWrongStringLength uint8 `toml:"er_wrong_string_length"` - ErWrongSubKey uint8 `toml:"er_wrong_sub_key"` - ErWrongTableName uint8 `toml:"er_wrong_table_name"` - ErWrongUsage uint8 `toml:"er_wrong_usage"` - ErWrongValueCountOnRow uint8 `toml:"er_wrong_value_count_on_row"` - ErWrongValueForVar uint8 `toml:"er_wrong_value_for_var"` -} - -var DefaultLevel = IncLevel2{ - ErAlterTableOnce: 1, - ErAutoIncrIdWarning: 1, - ErAutoincUnsigned: 1, - ErBadFieldError: 2, - ErBadNullError: 2, - ErBinlogCorrupted: 2, - ErBinlogFormatStatement: 2, - ErBlobCantHaveDefault: 1, - ErBlobUsedAsKey: 2, - ErCantChangeColumn: 1, - ErCantChangeColumnPosition: 1, - ErCantDropDatabase: 2, - ErCantDropFieldOrKey: 2, - ErCantDropTable: 2, - ErCantRemoveAllFields: 2, - ErCantSetCharset: 1, - ErCantSetCollation: 1, - ErCantSetEngine: 1, - ErChangeColumnType: 1, - ErChangeTooMuchRows: 1, - ErCharToVarcharLen: 1, - ErCharsetNotSupport: 2, - ErCharsetOnColumn: 1, - ErCollationCharsetMismatch: 2, - ErCollationNotSupport: 2, - ErColumnExisted: 2, - ErColumnHaveNoComment: 1, - ErColumnNotExisted: 2, - ErColumnsMustHaveIndex: 1, - ErColumnsMustHaveIndexTypeErr: 1, - ErConCountError: 2, - ErConflictingDeclarations: 2, - ErDataTooLong: 2, - ErDbNotExistedError: 2, - ErDdlDmlCoexist: 2, - ErDupFieldname: 2, - ErDupIndex: 2, - ErDupKeyname: 2, - ErEndWithCommit: 2, - ErEndWithSemicolon: 2, - ErEngineNotSupport: 2, - ErErrorExistBefore: 2, - ErFieldNotInGroupBy: 2, - ErFieldSpecifiedTwice: 2, - ErFloatDoubleToDecimal: 2, - ErForcingClose: 2, - ErForeignKey: 2, - ErHaveBegin: 2, - ErHostname: 2, - ErIdIsUper: 2, - ErIdentUseKeyword: 1, - ErIdentifierLower: 2, - ErIdentifierUpper: 2, - ErImplicitTypeConversion: 1, - ErIncInitErr: 1, - ErInceptionEmptyQuery: 2, - ErIncorrectDatetimeValue: 2, - ErIncorrectGlobalLocalVar: 2, - ErIndexNameIdxPrefix: 1, - ErIndexNameUniqPrefix: 1, - ErIndexUseAlterTable: 2, - ErInsertTooMuchRows: 1, - ErInvalidBackupHostInfo: 2, - ErInvalidCommand: 2, - ErInvalidDataType: 1, - ErInvalidDefault: 2, - ErInvalidGroupFuncUse: 2, - ErInvalidIdent: 1, - ErInvalidOnUpdate: 2, - ErJoinNoOnCondition: 1, - ErJsonTypeSupport: 2, - ErKeyColumnDoesNotExits: 2, - ErMariadbRollbackWarn: 1, - ErMaxColumnCount: 1, - ErMaxVarcharLength: 2, - ErMixOfGroupFuncAndFields: 2, - ErMultiplePriKey: 2, - ErMustAtLeastOneColumn: 2, - ErMustHaveColumns: 1, - ErNetPacketsOutOfOrder: 2, - ErNetReadError: 2, - ErNetReadInterrupted: 2, - ErNetworkReadEventChecksumFailure: 2, - ErNoDbError: 2, - ErNoWhereCondition: 1, - ErNonUniqError: 2, - ErNonUniqTable: 2, - ErNormalShutdown: 2, - ErNotAllowedNullable: 1, - ErNotFoundMasterStatus: 2, - ErNotFoundTableInfo: 1, - ErNotSupportedAlterOption: 1, - ErNotSupportedItemType: 2, - ErNotSupportedKeyType: 2, - ErNotSupportedYet: 2, - ErNotValidPassword: 2, - ErOrderyByRand: 1, - ErOscKillFailed: 2, - ErOutofmemory: 1, - ErParseError: 2, - ErPartitionNotAllowed: 1, - ErPartitionNotExisted: 2, - ErPkColsNotInt: 1, - ErPkTooManyParts: 1, - ErPrimaryCantHaveNull: 2, - ErRemoteExeError: 2, - ErRemovedSpaces: 2, - ErRepeatConstDefinition: 2, - ErSameNamePartition: 2, - ErSelectOnlyStar: 1, - ErSetDataTypeIntBigint: 2, - ErShutdownComplete: 2, - ErSlaveCorruptEvent: 2, - ErSlaveRelayLogWriteFailure: 2, - ErSqlInvalidOpType: 2, - ErSqlInvalidSource: 2, - ErSqlNoOpType: 2, - ErSqlNoSource: 2, - ErStartAsBegin: 2, - ErSyntaxError: 2, - ErTableCantHandleAutoIncrement: 2, - ErTableCharsetMustNull: 1, - ErTableCharsetMustUtf8: 1, - ErTableCollationNotSupport: 1, - ErTableExistsError: 2, - ErTableMustHaveComment: 1, - ErTableMustHavePk: 1, - ErTableNotExistedError: 2, - ErTablePrefix: 1, - ErTempTableTmpPrefix: 1, - ErTextNotNullableError: 1, - ErTimestampDefault: 1, - ErTooLongBakdbName: 2, - ErTooLongIdent: 2, - ErTooLongIndexComment: 1, - ErTooLongKey: 2, - ErTooManyKeyParts: 1, - ErTooManyKeys: 1, - ErTooMuchAutoTimestampCols: 2, - ErTruncatedWrongValue: 2, - ErUdpateTooMuchRows: 1, - ErUnknownCharacterSet: 2, - ErUnknownCharset: 1, - ErUnknownCollation: 1, - ErUnknownSystemVariable: 2, - ErUnknownTable: 2, - ErUseEnum: 1, - ErUseIndexVisibility: 2, - ErUseTextOrBlob: 2, - ErUseValueExpr: 1, - ErUsername: 2, - ErVarcharToTextLen: 2, - ErViewSelectClause: 2, - ErViewSupport: 2, - ErWithDefaultAddColumn: 1, - ErWithInsertField: 1, - ErWithInsertValues: 2, - ErWithLimitCondition: 1, - ErWithOrderbyCondition: 1, - ErWrongAndExpr: 1, - ErWrongArguments: 2, - ErWrongAutoKey: 2, - ErWrongColumnName: 2, - ErWrongDbName: 2, - ErWrongKeyColumn: 2, - ErWrongNameForIndex: 2, - ErWrongStringLength: 2, - ErWrongSubKey: 2, - ErWrongTableName: 2, - ErWrongUsage: 2, - ErWrongValueCountOnRow: 2, - ErWrongValueForVar: 2, -} diff --git a/config/generate_levels/main.go b/config/generate_levels/main.go index 98dad2b82..3642cd5c7 100644 --- a/config/generate_levels/main.go +++ b/config/generate_levels/main.go @@ -19,16 +19,22 @@ const tmpl = ` package config -type IncLevel2 struct { +type IncLevel struct { {{ range $opt := . }}` + " {{ $opt.OptionName }} uint8 `toml:\"{{ $opt.TomlValue }}\"`" + ` {{ end }}} -var DefaultLevel = IncLevel2 { +var defaultLevel = IncLevel { {{ range $opt := . }} {{ $opt.OptionName }}: {{ $opt.Level }}, {{ end }}} ` +const defaultToml = ` +[inc_level] +{{ range $opt := . }}{{ $opt.TomlValue }} = {{ $opt.Level }} +{{ end }} +` + func GenerateLevels() []ErrorLevel { results := make([]ErrorLevel, 0, len(session.ErrorsDefault)) for e := range session.ErrorsDefault { @@ -54,14 +60,24 @@ func GenerateLevels() []ErrorLevel { func main() { t := template.Must(template.New("tmpl").Parse(tmpl)) - file, err := os.OpenFile("config/error_level2.go", os.O_TRUNC|os.O_RDWR|os.O_CREATE, 0600) + file, err := os.OpenFile("config/error_level.go", os.O_TRUNC|os.O_RDWR|os.O_CREATE, 0600) if err != nil { panic(err) } - defer file.Close() err = t.Execute(file, GenerateLevels()) if err != nil { panic(err) } + file.Close() + t = template.Must(template.New("toml_default").Parse(defaultToml)) + file, err = os.OpenFile("config/config.toml.default.tmp", os.O_TRUNC|os.O_RDWR|os.O_CREATE, 0600) + if err != nil { + panic(err) + } + defer file.Close() + err = t.Execute(file, GenerateLevels()) + if err != nil { + panic(err) + } } diff --git a/session/errors.go b/session/errors.go index 4c49cf7b6..a57654b35 100644 --- a/session/errors.go +++ b/session/errors.go @@ -21,7 +21,6 @@ import ( "fmt" // "strconv" - "github.com/hanchuanchuan/goInception/config" "github.com/hanchuanchuan/goInception/mysql" "github.com/hanchuanchuan/goInception/terror" ) @@ -1109,220 +1108,3 @@ func (e ErrorCode) String() string { } return "" } - -// TestCheckAuditSetting 自动校准旧的审核规则和自定义规则 -func TestCheckAuditSetting(cnf *config.Config) { - return - - if cnf.Inc.CheckInsertField { - cnf.IncLevel.ER_WITH_INSERT_FIELD = int8(GetErrorLevel(ER_WITH_INSERT_FIELD)) - } else { - cnf.IncLevel.ER_WITH_INSERT_FIELD = 0 - } - - if cnf.Inc.CheckDMLWhere { - cnf.IncLevel.ER_NO_WHERE_CONDITION = int8(GetErrorLevel(ER_NO_WHERE_CONDITION)) - cnf.IncLevel.ErrJoinNoOnCondition = int8(GetErrorLevel(ErrJoinNoOnCondition)) - } else { - cnf.IncLevel.ER_NO_WHERE_CONDITION = 0 - cnf.IncLevel.ErrJoinNoOnCondition = 0 - } - - if cnf.Inc.CheckDMLLimit { - cnf.IncLevel.ER_WITH_LIMIT_CONDITION = int8(GetErrorLevel(ER_WITH_LIMIT_CONDITION)) - } else { - cnf.IncLevel.ER_WITH_LIMIT_CONDITION = 0 - } - - if cnf.Inc.CheckDMLOrderBy { - cnf.IncLevel.ER_WITH_ORDERBY_CONDITION = int8(GetErrorLevel(ER_WITH_ORDERBY_CONDITION)) - } else { - cnf.IncLevel.ER_WITH_ORDERBY_CONDITION = 0 - } - - if !cnf.Inc.EnableSelectStar { - cnf.IncLevel.ER_SELECT_ONLY_STAR = int8(GetErrorLevel(ER_SELECT_ONLY_STAR)) - } else { - cnf.IncLevel.ER_SELECT_ONLY_STAR = 0 - } - - if !cnf.Inc.EnableOrderByRand { - cnf.IncLevel.ER_ORDERY_BY_RAND = int8(GetErrorLevel(ER_ORDERY_BY_RAND)) - } else { - cnf.IncLevel.ER_ORDERY_BY_RAND = 0 - } - - if !cnf.Inc.EnableNullable { - cnf.IncLevel.ER_NOT_ALLOWED_NULLABLE = int8(GetErrorLevel(ER_NOT_ALLOWED_NULLABLE)) - } else { - cnf.IncLevel.ER_NOT_ALLOWED_NULLABLE = 0 - } - - if !cnf.Inc.EnableForeignKey { - cnf.IncLevel.ER_FOREIGN_KEY = int8(GetErrorLevel(ER_FOREIGN_KEY)) - } else { - cnf.IncLevel.ER_FOREIGN_KEY = 0 - } - - if !cnf.Inc.EnableBlobType { - if cnf.IncLevel.ER_USE_TEXT_OR_BLOB == 0 { - cnf.IncLevel.ER_USE_TEXT_OR_BLOB = int8(GetErrorLevel(ER_USE_TEXT_OR_BLOB)) - } - } else { - cnf.IncLevel.ER_USE_TEXT_OR_BLOB = 0 - } - - if !cnf.Inc.EnableJsonType { - if cnf.IncLevel.ErJsonTypeSupport == 0 { - cnf.IncLevel.ErJsonTypeSupport = int8(GetErrorLevel(ErrJsonTypeSupport)) - } - } else { - cnf.IncLevel.ErJsonTypeSupport = 0 - } - - if !cnf.Inc.EnableUseView { - cnf.IncLevel.ErrViewSupport = int8(GetErrorLevel(ErrViewSupport)) - } else { - cnf.IncLevel.ErrViewSupport = 0 - } - - if cnf.Inc.EnablePKColumnsOnlyInt { - cnf.IncLevel.ER_PK_COLS_NOT_INT = int8(GetErrorLevel(ER_PK_COLS_NOT_INT)) - } else { - cnf.IncLevel.ER_PK_COLS_NOT_INT = 0 - } - - if cnf.Inc.CheckTableComment { - cnf.IncLevel.ER_TABLE_MUST_HAVE_COMMENT = int8(GetErrorLevel(ER_TABLE_MUST_HAVE_COMMENT)) - } else { - cnf.IncLevel.ER_TABLE_MUST_HAVE_COMMENT = 0 - } - - if cnf.Inc.CheckColumnComment { - cnf.IncLevel.ER_COLUMN_HAVE_NO_COMMENT = int8(GetErrorLevel(ER_COLUMN_HAVE_NO_COMMENT)) - } else { - cnf.IncLevel.ER_COLUMN_HAVE_NO_COMMENT = 0 - } - - if cnf.Inc.CheckPrimaryKey { - cnf.IncLevel.ER_TABLE_MUST_HAVE_PK = int8(GetErrorLevel(ER_TABLE_MUST_HAVE_PK)) - } else { - cnf.IncLevel.ER_TABLE_MUST_HAVE_PK = 0 - } - - if !cnf.Inc.EnablePartitionTable { - cnf.IncLevel.ER_PARTITION_NOT_ALLOWED = int8(GetErrorLevel(ER_PARTITION_NOT_ALLOWED)) - } else { - cnf.IncLevel.ER_PARTITION_NOT_ALLOWED = 0 - } - - if !cnf.Inc.EnableEnumSetBit { - cnf.IncLevel.ER_USE_ENUM = int8(GetErrorLevel(ER_USE_ENUM)) - } else { - cnf.IncLevel.ER_USE_ENUM = 0 - } - - if cnf.Inc.CheckIndexPrefix { - cnf.IncLevel.ER_INDEX_NAME_IDX_PREFIX = int8(GetErrorLevel(ER_INDEX_NAME_IDX_PREFIX)) - cnf.IncLevel.ER_INDEX_NAME_UNIQ_PREFIX = int8(GetErrorLevel(ER_INDEX_NAME_UNIQ_PREFIX)) - } else { - cnf.IncLevel.ER_INDEX_NAME_IDX_PREFIX = 0 - cnf.IncLevel.ER_INDEX_NAME_UNIQ_PREFIX = 0 - } - - if cnf.Inc.EnableAutoIncrementUnsigned { - cnf.IncLevel.ER_AUTOINC_UNSIGNED = int8(GetErrorLevel(ER_AUTOINC_UNSIGNED)) - } else { - cnf.IncLevel.ER_AUTOINC_UNSIGNED = 0 - } - - if cnf.Inc.CheckAutoIncrementInitValue { - cnf.IncLevel.ER_INC_INIT_ERR = int8(GetErrorLevel(ER_INC_INIT_ERR)) - } else { - cnf.IncLevel.ER_INC_INIT_ERR = 0 - } - - if cnf.Inc.CheckIdentifier { - cnf.IncLevel.ER_INVALID_IDENT = int8(GetErrorLevel(ER_INVALID_IDENT)) - } else { - cnf.IncLevel.ER_INVALID_IDENT = 0 - } - - if cnf.Inc.CheckAutoIncrementDataType { - cnf.IncLevel.ER_SET_DATA_TYPE_INT_BIGINT = int8(GetErrorLevel(ER_SET_DATA_TYPE_INT_BIGINT)) - } else { - cnf.IncLevel.ER_SET_DATA_TYPE_INT_BIGINT = 0 - } - - if cnf.Inc.CheckTimestampDefault { - cnf.IncLevel.ER_TIMESTAMP_DEFAULT = int8(GetErrorLevel(ER_TIMESTAMP_DEFAULT)) - } else { - cnf.IncLevel.ER_TIMESTAMP_DEFAULT = 0 - } - - if cnf.Inc.CheckTimestampCount { - cnf.IncLevel.ER_TOO_MUCH_AUTO_TIMESTAMP_COLS = int8(GetErrorLevel(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS)) - } else { - cnf.IncLevel.ER_TOO_MUCH_AUTO_TIMESTAMP_COLS = 0 - } - - if !cnf.Inc.EnableColumnCharset { - cnf.IncLevel.ER_CHARSET_ON_COLUMN = int8(GetErrorLevel(ER_CHARSET_ON_COLUMN)) - } else { - cnf.IncLevel.ER_CHARSET_ON_COLUMN = 0 - } - - if !cnf.Inc.EnableIdentiferKeyword { - cnf.IncLevel.ER_IDENT_USE_KEYWORD = int8(GetErrorLevel(ER_IDENT_USE_KEYWORD)) - } else { - cnf.IncLevel.ER_IDENT_USE_KEYWORD = 0 - } - - if cnf.Inc.CheckAutoIncrementName { - cnf.IncLevel.ER_AUTO_INCR_ID_WARNING = int8(GetErrorLevel(ER_AUTO_INCR_ID_WARNING)) - } else { - cnf.IncLevel.ER_AUTO_INCR_ID_WARNING = 0 - } - - if cnf.Inc.MergeAlterTable { - cnf.IncLevel.ER_ALTER_TABLE_ONCE = int8(GetErrorLevel(ER_ALTER_TABLE_ONCE)) - } else { - cnf.IncLevel.ER_ALTER_TABLE_ONCE = 0 - } - - if cnf.Inc.CheckColumnDefaultValue { - cnf.IncLevel.ER_WITH_DEFAULT_ADD_COLUMN = int8(GetErrorLevel(ER_WITH_DEFAULT_ADD_COLUMN)) - } else { - cnf.IncLevel.ER_WITH_DEFAULT_ADD_COLUMN = 0 - } - - if cnf.Inc.CheckColumnTypeChange { - cnf.IncLevel.ER_CHANGE_COLUMN_TYPE = int8(GetErrorLevel(ER_CHANGE_COLUMN_TYPE)) - } else { - cnf.IncLevel.ER_CHANGE_COLUMN_TYPE = 0 - } - - if cnf.Inc.CheckColumnPositionChange { - cnf.IncLevel.ErCantChangeColumnPosition = int8(GetErrorLevel(ErCantChangeColumnPosition)) - } else { - cnf.IncLevel.ErCantChangeColumnPosition = 0 - } - - if cnf.Inc.EnableChangeColumn { - cnf.IncLevel.ErCantChangeColumn = 0 - } else { - cnf.IncLevel.ErCantChangeColumn = int8(GetErrorLevel(ErCantChangeColumn)) - } - - if !cnf.Inc.EnableBlobNotNull { - cnf.IncLevel.ER_TEXT_NOT_NULLABLE_ERROR = int8(GetErrorLevel(ER_TEXT_NOT_NULLABLE_ERROR)) - } else { - cnf.IncLevel.ER_TEXT_NOT_NULLABLE_ERROR = 0 - } - - if cnf.Inc.CheckImplicitTypeConversion { - cnf.IncLevel.ErrImplicitTypeConversion = int8(GetErrorLevel(ErrImplicitTypeConversion)) - } else { - cnf.IncLevel.ErrImplicitTypeConversion = 0 - } -} diff --git a/session/session_inception.go b/session/session_inception.go index f9bc34cdd..9ed8056d5 100644 --- a/session/session_inception.go +++ b/session/session_inception.go @@ -2211,10 +2211,8 @@ func (s *session) parseIncLevel() { for i := 0; i < v.NumField(); i++ { if v.Field(i).CanInterface() { - a := v.Field(i).Int() - if a < 0 { - a = 0 - } else if a > 2 { + a := v.Field(i).Uint() + if a > 2 { a = 2 } if k := t.Field(i).Tag.Get("toml"); k != "" { diff --git a/session/session_inception_common_test.go b/session/session_inception_common_test.go index e233eb9a5..f3f105c60 100644 --- a/session/session_inception_common_test.go +++ b/session/session_inception_common_test.go @@ -185,9 +185,9 @@ func (s *testCommon) initSetUp(c *C) { inc.EnableDropTable = true incLevel := &config.GetGlobalConfig().IncLevel - incLevel.ER_USE_ENUM = 1 + incLevel.ErUseEnum = 1 incLevel.ErJsonTypeSupport = 1 - incLevel.ER_USE_TEXT_OR_BLOB = 1 + incLevel.ErUseTextOrBlob = 1 // mysql5.6测试用例会出错(docker映射对外的端口不一致) config.GetGlobalConfig().Ghost.GhostAliyunRds = true @@ -249,7 +249,6 @@ func (s *testCommon) tearDownTest(c *C) { }() config.GetGlobalConfig().Inc.EnableDropTable = true - session.TestCheckAuditSetting(config.GetGlobalConfig()) s.runCheck("show tables") c.Assert(int(s.getAffectedRows()), GreaterEqual, 1) @@ -292,7 +291,6 @@ func (s *testCommon) tearDownTest(c *C) { } func (s *testCommon) runCheck(sql string) { - session.TestCheckAuditSetting(config.GetGlobalConfig()) if s.isAPI { s.sessionService.LoadOptions(session.SourceOptions{ @@ -388,7 +386,6 @@ inception_magic_commit;` func (s *testCommon) mustRunExec(c *C, sql string) *testkit.Result { config.GetGlobalConfig().Inc.EnableDropTable = true - session.TestCheckAuditSetting(config.GetGlobalConfig()) if s.isAPI { s.sessionService.LoadOptions(session.SourceOptions{ diff --git a/session/session_inception_exec_test.go b/session/session_inception_exec_test.go index 45af58819..9f7d86d9a 100644 --- a/session/session_inception_exec_test.go +++ b/session/session_inception_exec_test.go @@ -79,8 +79,6 @@ func (s *testSessionIncExecSuite) testErrorCode(c *C, sql string, errors ...*ses s.tk = testkit.NewTestKitWithInit(c, s.store) } - session.TestCheckAuditSetting(config.GetGlobalConfig()) - res := s.runExec(sql) row := res.Rows()[s.getAffectedRows()-1] @@ -382,19 +380,19 @@ func (s *testSessionIncExecSuite) TestAlterTableDropColumn(c *C) { func (s *testSessionIncExecSuite) TestInsert(c *C) { config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 sql := "" // 字段警告 config.GetGlobalConfig().Inc.CheckInsertField = true - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 1 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 1 sql = "drop table if exists t1;create table t1(id int,c1 int);insert into t1 values(1,1);" s.testErrorCode(c, sql, session.NewErr(session.ER_WITH_INSERT_FIELD)) config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 sql = "drop table if exists t1;create table t1(id int,c1 int);insert into t1(id) values();" s.testErrorCode(c, sql, @@ -440,7 +438,7 @@ func (s *testSessionIncExecSuite) TestInsert(c *C) { func (s *testSessionIncExecSuite) TestUpdate(c *C) { config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 sql := "" // 表不存在 @@ -529,11 +527,11 @@ func (s *testSessionIncExecSuite) TestDelete(c *C) { saved := config.GetGlobalConfig().Inc defer func() { config.GetGlobalConfig().Inc = saved - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 1 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 1 }() config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 sql := "" sql = "drop table if exists t1" @@ -1133,7 +1131,7 @@ func (s *testSessionIncExecSuite) TestMaxExecutionTime(c *C) { func (s *testSessionIncExecSuite) TestPartition(c *C) { config.GetGlobalConfig().Inc.EnablePartitionTable = false - config.GetGlobalConfig().IncLevel.ER_PARTITION_NOT_ALLOWED = 2 + config.GetGlobalConfig().IncLevel.ErPartitionNotAllowed = 2 s.mustRunExec(c, "drop table if exists test_partition;") sql = `create table test_partition( diff --git a/session/session_inception_test.go b/session/session_inception_test.go index 8494fe108..4e2170dfc 100644 --- a/session/session_inception_test.go +++ b/session/session_inception_test.go @@ -207,7 +207,6 @@ func (s *testSessionIncSuite) runAudit(c *C) { sqls = append(sqls, a.sql) } - session.TestCheckAuditSetting(config.GetGlobalConfig()) a := `/*%s;--check=1;--backup=0;--enable-ignore-warnings;real_row_count=%v;*/ inception_magic_start; %s @@ -912,7 +911,7 @@ primary key(id)) comment 'test';` config.GetGlobalConfig().Inc.ColumnsMustHaveIndex = "" config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 // 测试表名大小写 sql = `drop table if exists t1;CREATE TABLE t1(c1 int);insert into T1 values(1);` @@ -1547,7 +1546,7 @@ func (s *testSessionIncSuite) TestAlterTableDropColumn(c *C) { func (s *testSessionIncSuite) TestInsert(c *C) { config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 // 表不存在 sql = "insert into t1 values(1,1);" @@ -1578,12 +1577,12 @@ func (s *testSessionIncSuite) TestInsert(c *C) { // 字段警告 config.GetGlobalConfig().Inc.CheckInsertField = true - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 1 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 1 sql = "create table t1(id int,c1 int);insert into t1 values(1,1);" s.testErrorCode(c, sql, session.NewErr(session.ER_WITH_INSERT_FIELD)) config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 sql = "create table t1(id int,c1 int);insert into t1(id) values();" s.testErrorCode(c, sql, @@ -2013,7 +2012,7 @@ func (s *testSessionIncSuite) TestUpdate(c *C) { }() config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 config.GetGlobalConfig().Inc.EnableSetEngine = true // 表不存在 @@ -2315,7 +2314,7 @@ WHERE tt1.id=1;` func (s *testSessionIncSuite) TestDelete(c *C) { config.GetGlobalConfig().Inc.CheckInsertField = false - config.GetGlobalConfig().IncLevel.ER_WITH_INSERT_FIELD = 0 + config.GetGlobalConfig().IncLevel.ErWithInsertField = 0 // 表不存在 sql = "delete from t1 where c1 = 1;" @@ -3434,10 +3433,10 @@ func (s *testSessionIncSuite) TestWhereCondition(c *C) { s.mustRunExec(c, "drop table if exists t1,t2;create table t1(id int);") sql = "update t1 set id = 1 where 123;" - config.GetGlobalConfig().IncLevel.ErrUseValueExpr = 0 + config.GetGlobalConfig().IncLevel.ErUseValueExpr = 0 s.testErrorCode(c, sql) - config.GetGlobalConfig().IncLevel.ErrUseValueExpr = 1 + config.GetGlobalConfig().IncLevel.ErUseValueExpr = 1 s.testErrorCode(c, sql, session.NewErr(session.ErrUseValueExpr)) @@ -3517,9 +3516,9 @@ func (s *testSessionIncSuite) TestGroupBy(c *C) { // TestCheckAuditSetting 自动校准旧的审核规则和自定义规则, 保证两者一致 func (s *testSessionIncSuite) TestCheckAuditSetting(c *C) { configLevel := &config.GetGlobalConfig().IncLevel - configLevel.ER_USE_ENUM = 1 + configLevel.ErUseEnum = 1 configLevel.ErJsonTypeSupport = 2 - configLevel.ER_USE_TEXT_OR_BLOB = 2 + configLevel.ErUseTextOrBlob = 2 obj := config.GetGlobalConfig().IncLevel t := reflect.TypeOf(obj) @@ -3529,10 +3528,8 @@ func (s *testSessionIncSuite) TestCheckAuditSetting(c *C) { for i := 0; i < v.NumField(); i++ { if v.Field(i).CanInterface() { - a := v.Field(i).Int() - if a < 0 { - a = 0 - } else if a > 2 { + a := v.Field(i).Uint() + if a > 2 { a = 2 } if k := t.Field(i).Tag.Get("toml"); k != "" {