syntax = "proto3";

package yandex.cloud.mdb.mysql.v1.config;

import "google/protobuf/wrappers.proto";
import "yandex/cloud/validation.proto";

option go_package = "github.com/yandex-cloud/go-genproto/yandex/cloud/mdb/mysql/v1/config;mysql";
option java_package = "yandex.cloud.api.mdb.mysql.v1.config";

// Options and structure of `MysqlConfig5_7` reflects MySQL 5.7 configuration file
message MysqlConfig5_7 {
  enum SQLMode {
    SQLMODE_UNSPECIFIED = 0;

    ALLOW_INVALID_DATES = 1;

    ANSI_QUOTES = 2;

    ERROR_FOR_DIVISION_BY_ZERO = 3;

    HIGH_NOT_PRECEDENCE = 4;

    IGNORE_SPACE = 5;

    NO_AUTO_VALUE_ON_ZERO = 6;

    NO_BACKSLASH_ESCAPES = 7;

    NO_ENGINE_SUBSTITUTION = 8;

    NO_UNSIGNED_SUBTRACTION = 9;

    NO_ZERO_DATE = 10;

    NO_ZERO_IN_DATE = 11;

    NO_FIELD_OPTIONS = 12;

    NO_KEY_OPTIONS = 13;

    NO_TABLE_OPTIONS = 14;

    ONLY_FULL_GROUP_BY = 15;

    PAD_CHAR_TO_FULL_LENGTH = 16;

    PIPES_AS_CONCAT = 17;

    REAL_AS_FLOAT = 18;

    STRICT_ALL_TABLES = 19;

    STRICT_TRANS_TABLES = 20;

    ANSI = 21;

    TRADITIONAL = 22;

    DB2 = 23;

    MAXDB = 24;

    MSSQL = 25;

    MYSQL323 = 26;

    MYSQL40 = 27;

    ORACLE = 28;

    POSTGRESQL = 29;

    NO_AUTO_CREATE_USER = 30;

    NO_DIR_IN_CREATE = 31;
  }

  enum AuthPlugin {
    AUTH_PLUGIN_UNSPECIFIED = 0;

    // Using [Native Pluggable Authentication](https://dev.mysql.com/doc/refman/5.7/en/native-pluggable-authentication.html).
    MYSQL_NATIVE_PASSWORD = 1;

    CACHING_SHA2_PASSWORD = 2 [deprecated=true];

    // Using [SHA-256 Pluggable Authentication](https://dev.mysql.com/doc/refman/5.7/en/sha256-pluggable-authentication.html).
    SHA256_PASSWORD = 3;
  }

  enum TransactionIsolation {
    TRANSACTION_ISOLATION_UNSPECIFIED = 0;

    READ_COMMITTED = 1;

    REPEATABLE_READ = 2;

    SERIALIZABLE = 3;
  }

  enum BinlogRowImage {
      BINLOG_ROW_IMAGE_UNSPECIFIED = 0;

      FULL = 1;

      MINIMAL = 2;

      NOBLOB = 3;
  }

  enum SlaveParallelType {
      SLAVE_PARALLEL_TYPE_UNSPECIFIED = 0;

      DATABASE = 1;

      LOGICAL_CLOCK = 2;
  }

  // Size of the InnoDB buffer pool used for caching table and index data.
  //
  // For details, see [MySQL documentation for the parameter](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_buffer_pool_size).
  google.protobuf.Int64Value innodb_buffer_pool_size = 1 [(value) = ">=5242880"];

  // The maximum permitted number of simultaneous client connections.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_connections).
  google.protobuf.Int64Value max_connections = 2 [(value) = "10-16384"];

  // Time that it takes to process a query before it is considered slow.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_long_query_time).
  google.protobuf.DoubleValue long_query_time = 3;

  // Enable writing of general query log of MySQL.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_general_log).
  google.protobuf.BoolValue general_log = 4;

  // Enable writing of audit log of MySQL.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/mysql-security-excerpt/5.6/en/audit-log-options-variables.html#option_mysqld_audit-log).
  google.protobuf.BoolValue audit_log = 5;

  // Server SQL mode of MySQL.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-setting).
  repeated SQLMode sql_mode = 6;

  // The maximum size in bytes of one packet.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_allowed_packet).
  google.protobuf.Int64Value max_allowed_packet = 7 [(value) = "1024-1073741824"];

  // Authentication plugin used in the managed MySQL cluster.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_default_authentication_plugin)
  AuthPlugin default_authentication_plugin = 8;

  // Transaction log flush behaviour.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit)
  google.protobuf.Int64Value innodb_flush_log_at_trx_commit = 9 [(value) = "1-2"];

  // Max time in seconds for a transaction to wait for a row lock
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout)
  google.protobuf.Int64Value innodb_lock_wait_timeout = 10 [(value) = "1-28800"];

  // Default transaction isolation level.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_transaction_isolation)
  TransactionIsolation transaction_isolation = 11;

  // Print information about deadlocks in error log
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_print_all_deadlocks)
  google.protobuf.BoolValue innodb_print_all_deadlocks = 12;

  // The number of seconds to wait for more data from a connection before aborting the read.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_net_read_timeout)
  google.protobuf.Int64Value net_read_timeout = 13 [(value) = "1-1200"];

  // The number of seconds to wait for a block to be written to a connection before aborting the write.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_net_write_timeout)
  google.protobuf.Int64Value net_write_timeout = 14 [(value) = "1-1200"];

  // The maximum permitted result length in bytes for the GROUP_CONCAT() function.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_group_concat_max_len)
  google.protobuf.Int64Value group_concat_max_len = 15 [(value) = "4-33554432"];

  // The maximum size of internal in-memory temporary tables.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_tmp_table_size)
  google.protobuf.Int64Value tmp_table_size = 16 [(value) = "1024-536870912"];

  // This variable sets the maximum size to which user-created MEMORY tables are permitted to grow.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_heap_table_size)
  google.protobuf.Int64Value max_heap_table_size = 17 [(value) = "16384-536870912"];

  // The servers default time zone.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_default-time-zone)
  string default_time_zone = 18;

  // The servers default character set.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_character_set_server)
  string character_set_server = 19;

  // The server default collation.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_collation_server)
  string collation_server = 20;

  // Enables Innodb adaptive hash index
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_adaptive_hash_index)
  google.protobuf.BoolValue innodb_adaptive_hash_index = 21;

  // Enables the NUMA interleave memory policy for allocation of the InnoDB buffer pool.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_numa_interleave)
  google.protobuf.BoolValue innodb_numa_interleave = 22;

  // The size in bytes of the buffer that InnoDB uses to write to the log files on disk.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_log_buffer_size)
  google.protobuf.Int64Value innodb_log_buffer_size = 23 [(value) = "1048576-268435456"];

  // The size in bytes of the single Innodb Redo log file.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_log_file_size)
  google.protobuf.Int64Value innodb_log_file_size = 24 [(value) = "268435456-4294967296"];

  // Limits IO available for InnoDB background tasks
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_io_capacity)
  google.protobuf.Int64Value innodb_io_capacity = 25 [(value) = "100-100000"];

  // Limits IO available for InnoDB background tasks
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_io_capacity_max)
  google.protobuf.Int64Value innodb_io_capacity_max = 26 [(value) = "100-100000"];

  // The number of I/O threads for read operations in InnoDB.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_read_io_threads)
  google.protobuf.Int64Value innodb_read_io_threads = 27 [(value) = "1-16"];

  // The number of I/O threads for write operations in InnoDB.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_write_io_threads)
  google.protobuf.Int64Value innodb_write_io_threads = 28 [(value) = "1-16"];

  // The number of background threads devoted to the InnoDB purge operation.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_purge_threads)
  google.protobuf.Int64Value innodb_purge_threads = 29 [(value) = "1-16"];

  // Defines the maximum number of threads permitted inside of InnoDB.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_thread_concurrency)
  google.protobuf.Int64Value innodb_thread_concurrency = 30 [(value) = "0-1000"];

  // Limits the max size of InnoDB temp tablespace
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_temp_data_file_path)
  google.protobuf.Int64Value innodb_temp_data_file_max_size = 31 [(value) = "0-107374182400"];

  // How many threads the server should cache for reuse.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_thread_cache_size).
  google.protobuf.Int64Value thread_cache_size = 32 [(value) = "10-10000"];

  // The stack size for each thread. The default is large enough for normal operation.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_thread_stack).
  google.protobuf.Int64Value thread_stack = 33 [(value) = "131072-16777216"];

  // The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes and thus perform full table scans.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_join_buffer_size).
  google.protobuf.Int64Value join_buffer_size = 34 [(value) = "1024-16777216"];

  // Each session that must perform a sort allocates a buffer of this size.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sort_buffer_size).
  google.protobuf.Int64Value sort_buffer_size = 35 [(value) = "1024-16777216"];

  // The number of table definitions that can be stored in the definition cache.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache).
  google.protobuf.Int64Value table_definition_cache = 36 [(value) = "400-524288"];

  // The number of open tables for all threads.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_open_cache).
  google.protobuf.Int64Value table_open_cache = 37 [(value) = "400-524288"];

  // The number of open tables cache instances.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_open_cache_instances).
  google.protobuf.Int64Value table_open_cache_instances = 38 [(value) = "1-32"];

  // This system variable determines whether the server enables certain nonstandard behaviors for default values and NULL-value handling in TIMESTAMP columns.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp).
  google.protobuf.BoolValue explicit_defaults_for_timestamp = 39;

  // Can be used to control the operation of AUTO_INCREMENT columns.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-master.html#sysvar_auto_increment_increment).
  google.protobuf.Int64Value auto_increment_increment = 40 [(value) = "1-65535"];

  // Can be used to control the operation of AUTO_INCREMENT columns.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-master.html#sysvar_auto_increment_offset).
  google.protobuf.Int64Value auto_increment_offset = 41 [(value) = "1-65535"];

  // Controls how often the MySQL server synchronizes the binary log to disk.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_sync_binlog).
  google.protobuf.Int64Value sync_binlog = 42 [(value) = "0-4096"];

  // The size of the cache to hold changes to the binary log during a transaction.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_binlog_cache_size).
  google.protobuf.Int64Value binlog_cache_size = 43 [(value) = "4096-67108864"];

  // Controls how many microseconds the binary log commit waits before synchronizing the binary log file to disk.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_binlog_group_commit_sync_delay).
  google.protobuf.Int64Value binlog_group_commit_sync_delay = 44 [(value) = "0-1000000"];

  // For MySQL row-based replication, this variable determines how row images are written to the binary log.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_binlog_row_image).
  BinlogRowImage binlog_row_image = 45;

  // When enabled, it causes the server to write informational log events such as row query log events into its binary log.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_binlog_rows_query_log_events).
  google.protobuf.BoolValue binlog_rows_query_log_events = 46;

  // The number of replica acknowledgments the source must receive per transaction before proceeding.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-master.html#sysvar_rpl_semi_sync_master_wait_for_slave_count).
  google.protobuf.Int64Value rpl_semi_sync_master_wait_for_slave_count = 47 [(value) = "1-2"];

  // When using a multithreaded replica, this variable specifies the policy used to decide which transactions are allowed to execute in parallel on the replica.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-replica.html#sysvar_slave_parallel_type).
  SlaveParallelType slave_parallel_type = 48;

  // Sets the number of applier threads for executing replication transactions in parallel.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/replication-options-replica.html#sysvar_slave_parallel_workers).
  google.protobuf.Int64Value slave_parallel_workers = 49 [(value) = "0-64"];

  // The size of the binary log to hold.
  google.protobuf.Int64Value mdb_preserve_binlog_bytes = 50 [(value) = "1073741824-107374182400"];

  // The number of seconds the server waits for activity on an interactive connection before closing it.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_interactive_timeout).
  google.protobuf.Int64Value interactive_timeout = 51 [(value) = "600-86400"];

  // The number of seconds the server waits for activity on a noninteractive connection before closing it.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_wait_timeout).
  google.protobuf.Int64Value wait_timeout = 52 [(value) = "600-86400"];

  // Replication lag threshold (seconds) which will switch MySQL to 'offline_mode = ON' to prevent users from reading stale data.
  google.protobuf.Int64Value mdb_offline_mode_enable_lag = 53 [(value) = "600-432000"];

  // Replication lag threshold (seconds) which will switch MySQL to 'offline_mode = OFF'.
  // Should be less than mdb_offline_mode_enable_lag.
  google.protobuf.Int64Value mdb_offline_mode_disable_lag = 54 [(value) = "60-86400"];

  // The limit on memory consumption for the range optimizer.
  //
  // For details, see [MySQL documentation for the variable](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_range_optimizer_max_mem_size).
  google.protobuf.Int64Value range_optimizer_max_mem_size = 55 [(value) = "1048576-268435456"];
}

message MysqlConfigSet5_7 {
  // Effective settings for a MySQL 5.7 cluster (a combination of settings defined
  // in [user_config] and [default_config]).
  MysqlConfig5_7 effective_config = 1;

  // User-defined settings for a MySQL 5.7 cluster.
  MysqlConfig5_7 user_config = 2;

  // Default configuration for a MySQL 5.7 cluster.
  MysqlConfig5_7 default_config = 3;
}
