7¤0ì•@D�E�   & ` ` �€0ð<¡M´uewÃº}Ù¾¤Ôå[bžíû½Â4³ßî|gYÅ¸n³h\^+Àìð<‹£  ‰H&¬Û` •�#š“Î%òX9Œ¢ „Œ1ÆBˆ1DfhF$   ÄµÆ¹žt
C                   mysql, int errcode, const char *sqlstate);
void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate,
                              const char *format, ...)
                              ATTRIBUTE_FORMAT(printf, 4, 5);

/* client side of the pluggable authentication */
struct st_vio;
struct st_plugin_vio_info;
void mpvio_info(struct st_vio *vio, struct st_plugin_vio_info *info);
int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
                    const char *data_plugin, const char *db);
int mysql_client_plugin_init();
void mysql_client_plugin_deinit();
struct st_mysql_client_plugin;
extern struct st_mysql_client_plugin *mysql_client_builtins[];
uchar * send_client_connect_attrs(MYSQL *mysql, uchar *buf);

#ifdef	__cplusplus
}
#endif

#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)

#endif /* SQL_COMMON_INCLUDED */
#ifndef MARIADB_PLUGIN_DATA_TYPE_INCLUDED
#define MARIADB_PLUGIN_DATA_TYPE_INCLUDED
/* Copyright (C) 2019, Alexander Barkov and MariaDB

   Thad_pos;
  my_socket fd;					/* For Perl DBI/dbd */
  unsigned long remain_in_buf,length;
  unsigned long buf_length, where_b;
  unsigned long max_packet, max_packet_size;
  unsigned int pkt_nr, compress_pkt_nr;
  unsigned int write_timeout, read_timeout, retry_count;
  int fcntl;
  unsigned int *return_status;
  unsigned char reading_or_writing;
  char save_char;
  char unused_1;
  unsigned char tls_verify_status;
  my_bool compress;
  my_bool unused_2;
  char *unused_3;
  unsigned int last_errno;
  unsigned char error;
  my_bool unused_5;
  my_bool unused_6;
  char last_error[MYSQL_ERRMSG_SIZE];
  char sqlstate[SQLSTATE_LENGTH+1];
  struct st_mariadb_net_extension *extension;
} NET;

#define packet_error ((unsigned int) -1)

/* used by mysql_set_server_option */
enum enum_mysql_set_option
{
  MYSQL_OPTION_MULTI_STATEMENTS_ON,
  MYSQL_OPTION_MULTI_STATEMENTS_OFF
};

/* for status callback function */
enum enum_mariadb_status_info
{
  STATUS_TYPE= 0,
  SESSION_TRACK_TYPE
};

enum enum_session_state_type
{
  SEALL_PSI
#ifndef DISABLE_PSI_MEMORY
#define HAVE_PSI_MEMORY_INTERFACE
#endif /* DISABLE_PSI_MEMORY */
#endif /* DISABLE_ALL_PSI */
#endif /* HAVE_PSI_INTERFACE */

struct PSI_thread;

#ifdef HAVE_PSI_1

/**
  @defgroup Group_PSI_v1 Application Binary Interface, version 1
  @ingroup Instrumentation_interface
  @{
*/

/**
  Memory instrument information.
  @since PSI_VERSION_1
  This structure is used to register instrumented memory.
*/
struct PSI_memory_info_v1
{
  /** Pointer to the key assigned to the registered memory. */
  PSI_memory_key *m_key;
  /** The name of the memory instrument to register. */
  const char *m_name;
  /**
    The flags of the socket instrument to register.
    @sa PSI_FLAG_GLOBAL
  */
  int m_flags;
};
typedef struct PSI_memory_info_v1 PSI_memory_info_v1;

/**
  Memory registration API.
  @param category a category name (typically a plugin name)
  @param info an array of memory info to register
  @param count the size of the info array
*/
typedef void (*register_memory_v1_t)
  (const ELECT, intern
#define OPTION_INSERT_HISTORY           (1ULL << 30)
/** If not set then the thread will ignore all warnings with level notes. */
#define OPTION_SQL_NOTES                (1ULL << 31) // THD, user
/**
  Force the used temporary table to be a MyISAM table (because we will use
  fulltext functions when reading from it.
*/
#define TMP_TABLE_FORCE_MYISAM          (1ULL << 32)
#define OPTION_PROFILING                (1ULL << 33)
/**
  Indicates that this is a HIGH_PRIORITY SELECT.
  Currently used only for printing of such selects.
  Type of locks to be acquired is specified directly.
*/
#define SELECT_HIGH_PRIORITY            (1ULL << 34)     // SELECT, user
/**
  Is set in slave SQL thread when there was an
  error on master, which, when is not reproducible
  on slave (i.e. the query succeeds on slave),
  is not terminal to the state of repliation,
  and should be ignored. The slave SQL thread,
  however, needs to rollback the effects of the
  succeeded statement to keep replication consistent.
*/
#r_arg, uchar null_bit_arg,
              enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
              TABLE_SHARE *share, uint len_arg)
     : Field_varstring(ptr_arg, len_arg, len_arg < 256 ? 1 :2, null_ptr_arg,
                       null_bit_arg, unireg_check_arg, field_name_arg, share,
                       &my_charset_bin) { }
  const Type_handler *type_handler() const override
  { return &type_handler_vector; }
  void sql_type(String &str) const override;
  int reset() override;
  Copy_func *get_copy_func(const Field *from) const override;
  int  store(const char *to, size_t length, CHARSET_INFO *charset) override;
  int  store(double nr) override;
  int  store(longlong nr, bool unsigned_val) override;
  int  store_decimal(const my_decimal *) override;
  enum_conv_type rpl_conv_type_from(const Conv_source &, const Relay_log_info *,
                                    const Conv_param &) const override;
  uint size_of() const  override { return sizeof(*this); }
  bool update_min(Field *     32))
#endif /* HAVE_mi_uint7korr */

#ifndef HAVE_mi_uint8korr
#define mi_uint8korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[7])) |\
                                    (((uint32) (((const uchar*) (A))[6])) << 8) |\
                                    (((uint32) (((const uchar*) (A))[5])) << 16) |\
                                    (((uint32) (((const uchar*) (A))[4])) << 24)) |\
                        (((ulonglong) (((uint32) (((const uchar*) (A))[3])) |\
                                    (((uint32) (((const uchar*) (A))[2])) << 8) |\
                                    (((uint32) (((const uchar*) (A))[1])) << 16) |\
                                    (((uint32) (((const uchar*) (A))[0])) << 24))) <<\
                                    32))
#endif /* HAVE_mi_uint8korr */

/* This one is for uniformity */
#define mi_int1store(T,A) *((uchar*)(T))= (uchar) (A)

#define mi_int2store(T,A)   { uint def_temp= (uint) (A) ;\
                              ((uchar*) (T))[1]= (uchar) (def_temp);\
    eport_password;

extern I_List<THD> threads;

/*
  Check that a binlog event (read from the relay log) is valid to update
  last_master_timestamp. That is, a valid event is one with a consistent
  timestamp which originated from a primary server.
*/
static inline bool event_can_update_last_master_timestamp(Log_event *ev)
{
  return ev && !(ev->is_artificial_event() || ev->is_relay_log_event() ||
                 (ev->when == 0));
}

#else
#define close_active_mi() /* no-op */
#endif /* HAVE_REPLICATION */

/* masks for start/stop operations on io and sql slave threads */
#define SLAVE_IO  1
#define SLAVE_SQL 2

/**
  @} (end of group Replication)
*/

#endif
/*
 * Generated by dheadgen(1).
 */

#ifndef	_PROBES_MYSQL_D
#define	_PROBES_MYSQL_D

#ifdef	__cplusplus
extern "C" {
#define MYSQL_DTRACE_DISABLED false
#else
#define MYSQL_DTRACE_DISABLED 0
#endif

#define	MYSQL_CONNECTION_START(arg0, arg1, arg2)
#define	MYSQL_CONNECTION_START_ENABLED() MYSQL_DTRACE_DISABLED
#define	MYSQL_CONNECTION_DONE(arg0, arg1)
#def

/*
  If the following is set, if first gives an error, second will be
  tried. Otherwise, if first fails, we fail.
*/
#define SLAVE_FORCE_ALL 4

/*
  Values for the option --replicate-events-marked-for-skip.
  Must match the names in replicate_events_marked_for_skip_names in sys_vars.cc
*/
#define RPL_SKIP_REPLICATE 0
#define RPL_SKIP_FILTER_ON_SLAVE 1
#define RPL_SKIP_FILTER_ON_MASTER 2


int init_slave();
int init_recovery(Master_info* mi, const char** errmsg);
bool init_slave_skip_errors(const char* arg);
bool init_slave_transaction_retry_errors(const char* arg);
int register_slave_on_master(MYSQL* mysql);
int terminate_slave_threads(Master_info* mi, int thread_mask,
			     bool skip_lock = 0);
int start_slave_threads(THD *thd,
                        bool need_slave_mutex, bool wait_for_start,
			Master_info* mi, const char* master_info_fname,
			const char* slave_info_fname, int thread_mask);
/*
  cond_lock is usually same as start_lock. It is needed for the case when
  start_lock is 0 which happens in most cases index_read will work just fine without
    order in result production. When this flag is set it is however safe to
    order all output started by index_read since most engines do this. With
    read_multi_range calls there is a specific flag setting order or not
    order so in those cases ordering of index output can be avoided.
    (InnoDB, HEAP, MyISAM)

    HA_READ_RANGE:
    Specify whether index can handle ranges, typically true for all
    ordered indexes and not true for hash indexes.
    Used by optimiser to check if ranges (as key >= 5) can be optimised
    by index.
    (InnoDB, MyISAM, HEAP)

    HA_ONLY_WHOLE_INDEX:
    Can't use part key searches. This is typically true for hash indexes
    and typically not true for ordered indexes.
    (Federated, HEAP)

    HA_KEYREAD_ONLY:
    Does the storage engine support index-only scans on this index.
    Enables use of HA_EXTRA_KEYREAD and HA_EXTRA_NO_KEYREAD
    Used to set key_map keys_for_keyread and to check in optimiser for
    indexifier from a GTID. The type of the
  filter identifier is a template for the class.
*/
template <typename T>
class Id_delegating_gtid_event_filter : public Gtid_event_filter
{
public:
  Id_delegating_gtid_event_filter();
  ~Id_delegating_gtid_event_filter();

  my_bool exclude(rpl_gtid *gtid) override;
  my_bool has_finished() override;
  bool verify_final_state() override;
  void set_default_filter(Gtid_event_filter *default_filter);

  uint32 get_filter_type() override { return DELEGATING_GTID_FILTER_TYPE; }

  virtual T get_id_from_gtid(rpl_gtid *) = 0;
  virtual const char* get_id_type_name() = 0;

  /*
    Sets restrictions on entire ids using the corresponding mode (i.e. either
    whitelist or blacklist, refer to Gtid_event_filter::id_restriction_mode)

    A blacklist will allow all ids except for the ones provided in the input
    list.
    A whitelist will only allow ids provided in the input list.

    Returns 0 on ok, non-zero on error.
  */
  int set_id_restrictions(T *id_list, size_t n_ids,
    BLE(name, opt, comment, check, update, def, min, max, blk) \
DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \
  PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
  #name, comment, check, update, -1, def, min, max, blk, NULL }

/* accessor macros */

#define SYSVAR(name) \
  (*(MYSQL_SYSVAR_NAME(name).value))

/* when thd == null, result points to global value */
#define THDVAR(thd, name) \
  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))


/**
  Plugin description structure.
*/

struct st_mysql_plugin
{
  int type;             /**< the plugin type (a MYSQL_XXX_PLUGIN value)   */
  void *info;           /**< pointer to type-specific plugin descriptor   */
  const char *name;     /**< plugin name                                  */
  const char *author;   /**< plugin author (for I_S.PLUGINS)              */
  const char *descr;    /**< general descriptive text (for I_S.PLUGINS)   */
  int license;          /**< the plugin license (PLUGIN_LICENSE_XXX)      */
  /**
ners for the range filter and
       it lets the engine know that the filter will be used when
       accessing s.

  5. At the execution stage
       In the function sub_select() just before the first access of a join
       table s employing a range filter
         The method JOIN_TAB::build_range_rowid_filter_if_needed() is called
         The method fills the filter using the quick select created by
         JOIN::make_range_rowid_filters().

  6. The accessed key tuples are checked against the filter within the engine
     using the info pushed into it.

*/

struct TABLE;
class SQL_SELECT;
class Rowid_filter_container;
class Range_rowid_filter_cost_info;

typedef enum
{
  SORTED_ARRAY_CONTAINER,
  BLOOM_FILTER_CONTAINER      // Not used yet
} Rowid_filter_container_type;

/**
  @class Rowid_filter_container

  The interface for different types of containers to store info on the set
  of rowids / primary keys that defines a pk-filter.

  There will be two implementations of this abstract class.
  - sortedt
  {
    return part_type == VERSIONING_PARTITION &&
      thd->lex->vers_history_generating();
  }
  void vers_check_limit(THD *thd);
  bool vers_fix_field_list(THD *thd);
  void vers_update_el_ids();
  partition_element *get_partition(uint part_id)
  {
    List_iterator<partition_element> it(partitions);
    partition_element *el;
    while ((el= it++))
    {
      if (el->id == part_id)
        return el;
    }
    return NULL;
  }
  uint next_part_no(uint new_parts) const;

  int gen_part_type(THD *thd, String *str) const;
};

void part_type_error(THD *thd, partition_info *work_part_info,
                     const char *part_type, partition_info *tab_part_info);

uint32 get_next_partition_id_range(struct st_partition_iter* part_iter);
bool check_partition_dirs(partition_info *part_info);
bool vers_create_partitions(THD* thd, TABLE_LIST* tl, uint num_parts);

/* Initialize the iterator to return a single partition with given part_id */

static inline void init_single_partition_iterator(uint32 part_id,
  r_refresh, ulong timeout);
void purge_tables();
bool flush_tables(THD *thd, flush_tables_type flag);
void close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
                               ha_extra_function extra,
                               TABLE *skip_table);
OPEN_TABLE_LIST *list_open_tables(THD *thd, const LEX_CSTRING &db,
                                  const char *wild);
bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags);

TABLE *find_table_for_mdl_upgrade(THD *thd, const char *db,
                                  const char *table_name,
                                  int *p_error);
void mark_tmp_table_for_reuse(TABLE *table);

int dynamic_column_error_message(enum_dyncol_func_result rc);

/* open_and_lock_tables with optional derived handling */
int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived);

extern "C" int simple_raw_key_cmp(void *arg, const void *key1, const void *key2);
extern "C" int count_distinct_walk(void *elem, element_count count, void *record);
ha_rows hp_rb_records_in_range(HP_INFO *info, int inx,
                               const key_range *min_key,
                               const key_range *max_key);
int hp_panic(enum ha_panic_function flag);
int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key,
              key_part_map keypart_map, enum ha_rkey_function find_flag);
extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key);
extern int heap_check_heap(const HP_INFO *info, my_bool print_status);
extern uchar *heap_position(HP_INFO *info);

/* The following is for programs that uses the old HEAP interface where
   pointer to rows where a long instead of a (uchar*).
*/

#if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION)
extern int heap_rrnd_old(HP_INFO *info,uchar *buf,ulong pos);
extern ulong heap_position_old(HP_INFO *info);
#endif
#ifdef OLD_HEAP_VERSION
typedef ulong HEAP_PTR;
#define heap_position(A) heap_position_old(A)
#define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C)
#else
typedef uchar *HE_valid_expr_if_needed(THD *thd, Column_definition *c);
  static bool set_format_name(Send_field_extended_metadata *to)
  {
    static const Lex_cstring fmt(STRING_WITH_LEN("json"));
    return to->set_format_name(fmt);
  }
  static const Type_handler *json_type_handler(uint max_octet_length);
  static const Type_handler *json_blob_type_handler_by_length_bytes(uint len);
  static const Type_handler *json_type_handler_sum(const Item_sum *sum);
  static const Type_handler *json_type_handler_from_generic(const Type_handler *th);
  static bool has_json_valid_constraint(const Field *field);
  static const Type_collection *type_collection();
  static bool is_json_type_handler(const Type_handler *handler)
  {
    return handler->type_collection() == type_collection();
  }
};


template <class BASE, const Named_type_handler<BASE> &thbase>
class Type_handler_general_purpose_string_to_json:
                                            public BASE,
                                            public Type_handler_json_commo {
    MODE_IN,
    MODE_OUT,
    MODE_INOUT
  };

  /// Name of the SP-variable.
  Lex_ident_column name;

  /// Mode of the SP-variable.
  enum_mode mode;

  /// The index to the variable's value in the runtime frame.
  ///
  /// It is calculated during parsing and used when creating sp_instr_set
  /// instructions and Item_splocal items. I.e. values are set/referred by
  /// array indexing in runtime.
  uint offset;

  /// Default value of the SP-variable (if any).
  Item *default_value;

  /// Full type information (field meta-data) of the SP-variable.
  Spvar_definition field_def;

  /// Field-type of the SP-variable.
  const Type_handler *type_handler() const
    { return field_def.type_handler(); }

public:
  sp_variable(const LEX_CSTRING *name_arg, uint offset_arg)
   :Sql_alloc(),
    name(*name_arg),
    mode(MODE_IN),
    offset(offset_arg),
    default_value(NULL)
  { }
  /*
    Find a ROW field by its qualified name.
    @param      var_name - the name of the variable
    @param      field_name -NT) should never change their numbers
  */

  /* New MySQL events are to be added right above this comment */
  MYSQL_EVENTS_END,

  MARIA_EVENTS_BEGIN= 160,
  ANNOTATE_ROWS_EVENT= 160,
  BINLOG_CHECKPOINT_EVENT= 161,
  GTID_EVENT= 162,
  GTID_LIST_EVENT= 163,
  START_ENCRYPTION_EVENT= 164,
  QUERY_COMPRESSED_EVENT = 165,
  WRITE_ROWS_COMPRESSED_EVENT_V1 = 166,
  UPDATE_ROWS_COMPRESSED_EVENT_V1 = 167,
  DELETE_ROWS_COMPRESSED_EVENT_V1 = 168,
  WRITE_ROWS_COMPRESSED_EVENT = 169,
  UPDATE_ROWS_COMPRESSED_EVENT = 170,
  DELETE_ROWS_COMPRESSED_EVENT = 171,

  /* Add new MariaDB events here - right above this comment!  */

  ENUM_END_EVENT /* end marker */
};

/* ROWS_EVENT flags */

#define STMT_END_F                    0x01
#define NO_FOREIGN_KEY_CHECKS_F       0x02
#define RELAXED_UNIQUE_KEY_CHECKS_F   0x04
#define COMPLETE_ROWS_F               0x08
#define NO_CHECK_CONSTRAINT_CHECKS_F  0x80


enum mariadb_rpl_status_code {
  Q_FLAGS2_CODE= 0x00,
  Q_SQL_MODE_CODE= 0x01,
  Q_CATALOG_CODE= 0x02,
  Q_AUTO_INCREME 02110-1301  USA */

#ifndef SQL_TYPE_STRING_INCLUDED
#define SQL_TYPE_STRING_INCLUDED

class StringPack
{
  CHARSET_INFO *m_cs;
  uint32 m_octet_length;
  CHARSET_INFO *charset() const { return m_cs; }
  uint mbmaxlen() const { return m_cs->mbmaxlen; };
  uint32 char_length() const { return m_octet_length / mbmaxlen(); }
public:
  StringPack(CHARSET_INFO *cs, uint32 octet_length)
   :m_cs(cs),
    m_octet_length(octet_length)
  { }
  uchar *pack(uchar *to, const uchar *from, uint max_length) const;
  const uchar *unpack(uchar *to, const uchar *from, const uchar *from_end,
                      uint param_data) const;
public:
  static uint max_packed_col_length(uint max_length)
  {
    return (max_length > 255 ? 2 : 1) + max_length;
  }
  static uint packed_col_length(const uchar *data_ptr, uint length)
  {
    if (length > 255)
      return uint2korr(data_ptr)+2;
    return (uint) *data_ptr + 1;
  }
};


#endif // SQL_TYPE_STRING_INCLUDED
/* Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.

   Ts only valid if current_page != 0. */
    uchar *current_ptr;

    Index_node_base();
    ~Index_node_base();
    void free_pages();
    void reset();
  };

public:
  static void make_gtid_index_file_name(char *out_name, size_t bufsize,
                                        const char *base_filename);

protected:
  int update_gtid_state(rpl_binlog_state_base *state,
                        const rpl_gtid *gtid_list, uint32 gtid_count);
  Node_page *alloc_page();
  rpl_gtid *gtid_list_buffer(uint32 count);
  void build_index_filename(const char *filename);
  virtual int give_error(const char *msg) = 0;

  /*
    A buffer to hold a gtid_list temporarily.
    Increased as needed to hold largest needed list.
  */
  rpl_gtid *gtid_buffer;
  uint32 gtid_buffer_alloc;
  size_t page_size;
public:
  char index_file_name[GTID_INDEX_FILENAME_MAX_SIZE];

protected:
  Gtid_index_base();
  virtual ~Gtid_index_base();
};


class Gtid_index_writer : public Gtid_index_base
{
private:
  const my_off_t offset_min_threshold;

g. And how
    many commit_checkpoint_request()'s are pending.

    When count drops to zero in a binlog after rotation, it means that there
    are no more XIDs in prepared state, so that binlog is no longer needed
    for XA crash recovery, and we can log a new binlog checkpoint event.

    The list is protected against simultaneous access from multiple
    threads by LOCK_xid_list.
  */
  struct xid_count_per_binlog : public ilink {
    char *binlog_name;
    uint binlog_name_len;
    ulong binlog_id;
    /* Total prepared XIDs and pending checkpoint requests in this binlog. */
    long xid_count;
    xid_count_per_binlog(char *log_file_name, uint log_file_name_len)
      :binlog_id(0), xid_count(0)
    {
      binlog_name_len= log_file_name_len;
      binlog_name= (char *) my_malloc(PSI_INSTRUMENT_ME, binlog_name_len, MYF(MY_ZEROFILL));
      if (binlog_name)
        memcpy(binlog_name, log_file_name, binlog_name_len);
    }
    ~xid_count_per_binlog()
    {
      my_free(binlog_name);
    }
  };
  I_List///////
  // SQL-handlers.
  /////////////////////////////////////////////////////////////////////////

  /// Push an sp_instr_hpush_jump instance to the handler call stack.
  ///
  /// @param entry    The condition handler entry
  ///
  /// @return error flag.
  /// @retval false on success.
  /// @retval true on error.
  bool push_handler(sp_instr_hpush_jump *entry);

  /// Pop and delete given number of instances from the handler
  /// call stack.
  ///
  /// @param count Number of handler entries to pop & delete.
  void pop_handlers(size_t count);

  const Sql_condition_info *raised_condition() const
  {
    return m_handler_call_stack.elements() ?
      (*m_handler_call_stack.back())->sql_condition : NULL;
  }

  /// Handle current SQL condition (if any).
  ///
  /// This is the public-interface function to handle SQL conditions in
  /// stored routines.
  ///
  /// @param thd            Thread handle.
  /// @param ip[out]        Instruction pointer to the first handler
  ///                       instru  @file

  Encryption Plugin API.

  This file defines the API for server plugins that manage encryption
  keys for MariaDB on-disk data encryption.
*/

#define MYSQL_PLUGIN_ENCRYPTION_INCLUDED

#include <mysql/plugin.h>

#ifdef __cplusplus
extern "C" {
#endif

#define MariaDB_ENCRYPTION_INTERFACE_VERSION 0x0300

/**
  Encryption plugin descriptor
*/
struct st_mariadb_encryption
{
  int interface_version;                        /**< version plugin uses */

  /*********** KEY MANAGEMENT ********************************************/

  /**
    function returning latest key version for a given key id

    @return a version or ENCRYPTION_KEY_VERSION_INVALID to indicate an error.
  */
  unsigned int (*get_latest_key_version)(unsigned int key_id);

  /**
    function returning a key for a key version

    @param version      the requested key version
    @param key          the key will be stored there. Can be NULL -
                        in which case no key will be returned
    @param key_length   in: key buffew¢Ùni„™„YNÎš�mˆ§Dš«¥?@B©ÏÍ¦£¥ly¯5âz,�ÑÐzÝXW¦ìCÔ%§�¹UDG»û®´6‡mk­Ã³3P7Ö ”–×�z+?-õ=;kr�,ð2¶¨Æœª‡w•Ò´.[9I¨Q$$‰AJR4#A¤Iò€™2³À9SÖý¾âgeœ¾÷œw‹_Í[JÂo4ž¼_(ŒÀUy˜‚M%PhwM;"Èï,seP·&;ƒXº26Ñz‰¡Åï$W�-øšRðÝø#ÇÃpÅ€H'U(ò;ä³Îp!wÙO¿<£lR4šò¾¸¶.à:»i$ç@€¿kÃ)zGAT j(µ/ý`Ï] –`uHÐò& }i3gú(ÒíA–A·ApY} Eê •ÊO¬äÍi!¨zð–Ä>~ØÑç -}R #Pýñ9A{¹S
^ _ ^ ÙMzÚ]Ï¸ËÛ�~4c�DÈ§Û‰Êâðæ%÷óR�¬¼œ›FÐ¿Ó�ó£
Í%ÊÏçMÜ®²P ` ÞÀˆhE
fµƒý<nv×Qæs‹ÜöËvË~TWúEŽôÏË~)£ãŒ>ÉLâñÑî�!´¥ICoúíßÉ)ÛMà÷F„€¨Av×äÒ8¹äÙV²8J7V6¥J6çÆ�Gâð »L;žvCÏ¸KÇh?|Œ™Ë:QÌü'ž=páÇ¼Œš`'¨F}Lí¯5Ïs�!ôA}ÔdL›<8;•À£&£f£=‰œŠèT©vK†xžN¡…P ‡4ßvwU‹5æ/è¡ƒ…5f§Þtw_ú¹/‡a¥¸X¤…Ökåš/+ÕœV9‰YµTZ`*´|\<˜×Ç’q¹¨>—§à„Á	
Š‰j%å{IÁàÅ¬^«åâ­¸>•Áv¸×�{ÓNSd;¥±Ä´%á�¦…T¦)fScÛ=›" `1t×m<~S—x&¹”ÚÛ0Ñ‹lBÜxÍ¾ž9†Y@Ô)E,Ê¡ˆ»w£œ¦9F‰8&ÐA,g,5³_Ý>L�¬5»mp(µ/ý`5- ö·ÆI�ÚM:±“ß•B=¬è)~8ä-´æyuÍñ=×ÜåKP>î#ÇÇ…�ÍÃLÀ7Y‡˜�@ÝN�ëæø`_w´M‘F6‘;É³ £ µ 'Ø¼I°É½åå­Îø"÷ZbžmFX›ê­ ÃÃã�·å�·íÅ]y·ÝÎšYÒH;våñÅ^¹Hû¥¸�§ê·où°êùþJåE_ŒW("$ØòÁ¨µÔKŒ                                   S     0               ‡                                   \                     š                                     l                           0                                                    Ð      0                           	                                                                                                                      pvio_socket.c.o/1795707564  0     0     100644  60064     `
ELF          >                     Ý          @     @ 6 5 (µ/ý �              (µ/ý`L% ÖWE�8k$¢øóÍ]rt¬ˆ=W¹kÈa7‡0ÿqX=(ð²Án€ª
       B   „�Ëµö·›H³ÝÝÝDöÊ–¤H H A „hØP[Ò�É¥Ó»ñ0á‚e+¥�5¥6f°Ú}È˜Œ\××uÍ˜ÆÂ¡uªO_›€€ãDÓµ¤Pù~x)9Açó5!.§YÎªs×`|€¨LËg1h±òèÅL R<:v»­�½ù/yA”x Â±[;µc[6ŠSÇR!3Â½&+¬ØØ°­
0Ú…Â¢êÈlâ÷ððÿLWª‹É‹J÷€ƒwUAˆ�÷¼öÂÉŠCüþ¦$$‹$ôî¼ÍÉö°""á3ŸÝÝó¹qb¤TžÊ“¦X PÒZ3¦ Ç8@‘(§Æ Årnª¨‘–.‘•|Ü{ôž“äwvIN§£ˆt¸8z´è�xZa¨¡¡€C(M
*é@‚ «ò0GÆJ“¤Ù§áhú¸’¡¡yÚºƒ¸Çzè+ã|Afnó]/Ç‚0ªÇ+Êb°õ	<nüRöîJÚ ìÈž5Ž	\ð’³‹?o“£¨×PÈÐƒd»äQ9jàlØâÍ<Ïx[½ø¶Zƒ"õZ,ø¢ŠFÈ m7š’íºxÿ:ÌbàÞO5IæçáÑÛªÅ¿ÕÙƒG^‹[•H|Ç!ð|Ä#ÉI©Y‚—œŽ‚0-ùPJb*-%9ñh2‘”’z(5›N0	,z4“|$91-ù0BRJbrj*jrJÚQÔìáÂC)©ˆ©ÉYd‚�’˜NLKB„8›˜NKJÌ¦æR&S“S³‰Ù$Á‰éäÜÁTÑ£É”äÒdb6%1/È‘�&‘&#¥¥¤¦¦&“� K<zšLð‘ÄÔ$’AH�¦“‘�f%ÒF=š=”šNh9)5“€ðø2¤É„ ®SSé}øpîh{(5ŸÉÉéÈHIi‰‡¦%&¦¦«Ôb¤<r:êÑ.%Äe,ŒLRD‚“ó¨¨I)	É	DÈŽ$ E/XÄ`Ñ¢ÅŠ=Ž’˜Ž‚95•Š�~)ê$É¹£è3ÃI»�~Î�6¥IE{Y¡¡1¥èÎ¾5û\CúLÚh4ubÓ3§8õYß%eNÓ—wcÝÓ]‹¹3s ¡˜0p‰ùêò½‚ëõ”×h¬TyÚSJù¢¦ûÖ«Ý&tî–«ÕsF»Ë;ÝÖ˜Üë(™kœ¾Ö(OÀ†Ä}’k1îÆÔœØà‘×ÊþÍ%¢¦½ËjìJÉÝ¾å"µ$y›•Ë÷8.Ï„{'Þ÷–×B·E•Â2ý*ØÒcY†Õ½ ýö!¬ÄÐ~|#%›OKÖ‘Ë÷­åŸ­íÝí3Ð-Ù“r›f)ý¼ý�ÀY€*1H¥ûí7�Câæ‰Ï­’‚ž)ßÞ¥XÁº2
Nÿ€ôT¯XwÊE‚ýVÓ…µrµ‡Å*á±<g	ÎöÜ"µÝ÷]–Æò�Å•â@,/ÄJÕ5ËÄûî1Ì“˜¶§á8õZÖ¤ë;›c·Û·Ýõ™RO®Ô(ˆ,ëIÅAæöAen4‚6%#H>¬BHGBÛ£ë\‰Anå¹mvÝ·Ý[¯¼&Û÷•ßAA²½Ö›'H* ¶pœA†ŠTŽR%ÞkfžÎ¨ðhDDæ ÙÚcÀb„ÌJÕÞ­|‰$Ržö]×j´%K�35VÞí:…o+¿"‰7Røö!Í`©)4ûÚ,Ý½Aãácß}nÐv8•ï:î´¶£´×ÁJ¼f·X¿z<Ö%Aæ8öM9<ÐžŠC´ö“ûöCû!8^¨ªL¯tÙ�Øæj7{oÃˆ¦ÃÑ¾¿ôÙ÷—÷4fœÇ;:·+÷8/û§4OjúËs�‰ûÓ=|Ž[¸4žý¤ªêŸ
QKŽ[åµ# ²*ÿ/PU¥>åÝì��^^t]I¡-M`P
ÑE£Èqú8¯ston,
   MA 02111-1301, USA */

/*
  A better implementation of the UNIX ctype(3) library.
  Notes:   my_global.h should be included before ctype.h
*/

#ifndef _mariadb_ctype_h
#define _mariadb_ctype_h

#include <ctype.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define CHARSET_DIR	"charsets/"
#define MY_CS_NAME_SIZE 32

#define MADB_DEFAULT_CHARSET_NAME "latin1"
#define MADB_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
#define MADB_AUTODETECT_CHARSET_NAME "auto"

/* we use the mysqlnd implementation */
typedef struct ma_charset_info_st
{
  unsigned int	nr; /* so far only 1 byte for charset */
  unsigned int  state;
  const char	*csname;
  const char	*name;
  const char  *dir;
  unsigned int codepage;
  const char  *encoding;
  unsigned int	char_minlen;
  unsigned int	char_maxlen;
  unsigned int 	(*mb_charlen)(unsigned int c);
  unsigned int 	(*mb_valid)(const char *start, const char *end);
} MARIADB_CHARSET_INFO;

extern const MARIADB_CHARSET_INFO  mariadb_compiled_charsets[];
extern MARIADB_CHARSET_INFO *ma_de ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS 1910
#define ER_UNKNOWN_OPTION 1911
#define ER_BAD_OPTION_VALUE 1912
#define ER_UNUSED_6 1913
#define ER_UNUSED_7 1914
#define ER_UNUSED_8 1915
#define ER_DATA_OVERFLOW 1916
#define ER_DATA_TRUNCATED 1917
#define ER_BAD_DATA 1918
#define ER_DYN_COL_WRONG_FORMAT 1919
#define ER_DYN_COL_IMPLEMENTATION_LIMIT 1920
#define ER_DYN_COL_DATA 1921
#define ER_DYN_COL_WRONG_CHARSET 1922
#define ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES 1923
#define ER_QUERY_CACHE_IS_DISABLED 1924
#define ER_QUERY_CACHE_IS_GLOBALY_DISABLED 1925
#define ER_VIEW_ORDERBY_IGNORED 1926
#define ER_CONNECTION_KILLED 1927
#define ER_UNUSED_12 1928
#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SKIP_REPLICATION 1929
#define ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION 1930
#define ER_QUERY_RESULT_INCOMPLETE 1931
#define ER_NO_SUCH_TABLE_IN_ENGINE 1932
#define ER_TARGET_NOT_EXPLAINABLE 1933
#define ER_CONNECTION_ALREADY_EXISTS 1934
#define ER_MASTER_LOG_PREFIX 1935
#define ER_CANT_START_STOP_SLAVE 1.add_table_name(table);
    }
    return *this;
  }
  Json_writer_object& add_select_number(uint select_number)
  {
    DBUG_ASSERT(!closed);
    if (my_writer)
    {
      add_member("select_id");
      if (unlikely(select_number == FAKE_SELECT_LEX_ID))
        context.add_str("fake");
      else
        context.add_ll(static_cast<longlong>(select_number));
    }
    return *this;
  }
  void end()
  {
    DBUG_ASSERT(!closed);
    if (unlikely(my_writer))
      my_writer->end_object();
    closed= TRUE;
  }
};


/*
  RAII-based class to start/end writing a JSON array into the JSON document

  There is "ignore mode": one can initialize Json_writer_array with a NULL
  Json_writer argument, and then all its calls will do nothing. This is used
  by optimizer trace which can be enabled or disabled.
*/

class Json_writer_array : public Json_writer_struct
{
public:
  explicit Json_writer_array(Json_writer *writer, const char *str= nullptr)
    : Json_writer_struct(writer)
  {
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_{
    collation= DTCollation::string_typecast(cs);
    if (cache_if_const && args[0]->can_eval_in_optimize())
    {
      uint errors= 0;
      String tmp, *str= args[0]->val_str(&tmp);
      if (!str || str_value.copy(str->ptr(), str->length(),
                                 str->charset(), cs, &errors))
        null_value= 1;
      use_cached_value= 1;
      str_value.mark_as_const();
      safe= (errors == 0);
    }
    else
    {
      use_cached_value= 0;
      /*
        Conversion from and to "binary" is safe.
        Conversion to Unicode is safe.
        Conversion from an expression with the ASCII repertoire
        to any character set that can store characters U+0000..U+007F
        is safe:
        - All supported multibyte character sets can store U+0000..U+007F
        - All supported 7bit character sets can store U+0000..U+007F
          except those marked with MY_CS_NONASCII (e.g. swe7).
        Other kind of conversions are potentially lossy.
      */
      safe= (args[0]->collation.collaatural_sort_key>(thd, this);
  }

  bool check_vcol_func_processor(void *arg) override;
};

class Item_func_concat :public Item_str_func
{
protected:
  String tmp_value;
  /*
    Append a non-NULL value to the result.
    @param [IN]     thd          - The current thread.
    @param [IN/OUT] res          - The current val_str() return value.
    @param [IN]     app          - The value to be appended.
    @retval                      - false on success, true on error
  */
  bool append_value(THD *thd, String *res, const String *app);
  bool realloc_result(String *str, uint length) const;
public:
  Item_func_concat(THD *thd, List<Item> &list): Item_str_func(thd, list) {}
  Item_func_concat(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {}
  const Schema *schema() const override { return &mariadb_schema; }
  void print(String *str, enum_query_type query_type) override
  {
    print_sql_mode_qualified_name(str, query_type);
    print_args_parenthesized(str, query_type);
  }
  String *val_str(String *) ove_TABLE_ALGORITHM_NONE;
    requested_lock= ALTER_TABLE_LOCK_DEFAULT;
  }


  /**
    Construct a copy of this object to be used for mysql_alter_table
    and mysql_create_table.

    Historically, these two functions modify their Alter_info
    arguments. This behaviour breaks re-execution of prepared
    statements and stored procedures and is compensated by always
    supplying a copy of Alter_info to these functions.

    @param  rhs       Alter_info to make copy of
    @param  mem_root  Mem_root for new Alter_info

    @note You need to use check the error in THD for out
    of memory condition after calling this function.
  */
  Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);


  /**
     Parses the given string and sets requested_algorithm
     if the string value matches a supported value.
     Supported values: INPLACE, COPY, DEFAULT

     @param  str    String containing the supplied value
     @retval false  Supported value found, state updated
     @retval true   Not supported value, no chan    sql_query->append(get_expr_query());
  }

protected:
  LEX_CSTRING get_expr_query() const override
  {
    return m_query;
  }

  bool on_after_expr_parsing(THD *) override
  {
    m_valid= true;
    return false;
  }

public:
  PSI_statement_info* get_psi_info() override { return & psi_info; }
  static PSI_statement_info psi_info;
}; // class sp_instr_stmt : public sp_lex_instr


class sp_instr_set : public sp_lex_instr,
                     public sp_rcontext_addr
{
  sp_instr_set(const sp_instr_set &);	/**< Prevent use of these */
  void operator=(sp_instr_set &);

public:
  sp_instr_set(uint ip, sp_pcontext *ctx,
               const Sp_rcontext_handler *rh,
	       uint offset, Item *val,
               LEX *lex, bool lex_resp,
	       const LEX_CSTRING &expr_str)
    : sp_lex_instr(ip, ctx, lex, lex_resp),
      sp_rcontext_addr(rh, offset),
      m_value(val),
      m_expr_str(expr_str)
  {}

  virtual ~sp_instr_set() = default;

  int execute(THD *thd, uint *nextp) override;

  int exec_core(THD * vsetq_lane_u64(vgetq_lane_u64(step8, 1) * prime_mx2, step9, 1);
    return veorq_u64(step9, vshrq_n_u64(step9, 28));
  }

  uint64x2_t GetBlockIdx(uint64x2_t vecHash)
  {
    uint64x2_t vecNumBlocksMask= vdupq_n_u64(num_blocks - 1);
    uint64x2_t vecBlockIdx= vshrq_n_u64(vecHash, mask_idx_bits + rotate_bits);
    return vandq_u64(vecBlockIdx, vecNumBlocksMask);
  }

  uint64x2_t ConstructMask(uint64x2_t vecHash)
  {
    uint64x2_t vecMaskIdxMask= vdupq_n_u64((1 << mask_idx_bits) - 1);
    uint64x2_t vecMaskMask= vdupq_n_u64((1ull << bits_per_mask) - 1);

    uint64x2_t vecMaskIdx= vandq_u64(vecHash, vecMaskIdxMask);
    uint64x2_t vecMaskByteIdx= vshrq_n_u64(vecMaskIdx, 3);
    /*
      Shift right in NEON is implemented as shift left by a negative value.
      Do the negation here.
    */
    int64x2_t vecMaskBitIdx=
      vsubq_s64(vdupq_n_s64(0),
                vreinterpretq_s64_u64(vandq_u64(vecMaskIdx, vdupq_n_u64(0x7))));
    uint64x2_t vecRawMasks= vdupq_n_u64(*reinterpret_cast<const uint64_t*>
    ACHE_SIZE		(uint) (128L*1024L*1024L)
	/* Default size of a key cache block  */
#define KEY_CACHE_BLOCK_SIZE	(uint) 1024

	/* Some things that this system doesn't have */

#ifdef _WIN32
#define NO_DIR_LIBRARY		/* Not standard dir-library */
#endif

/* Some defines of functions for portability */

#undef remove		/* Crashes MySQL on SCO 5.0.0 */
#ifndef _WIN32
#define closesocket(A)	close(A)
#endif

#if defined(_MSC_VER)
#if !defined(_WIN64)
inline double my_ulonglong2double(unsigned long long value)
{
  long long nr=(long long) value;
  if (nr >= 0)
    return (double) nr;
  return (18446744073709551616.0 + (double) nr);
}
#define ulonglong2double my_ulonglong2double
#define my_off_t2double  my_ulonglong2double
#endif /* _WIN64 */
inline unsigned long long my_double2ulonglong(double d)
{
  double t= d - (double) 0x8000000000000000ULL;

  if (t >= 0)
    return  ((unsigned long long) t) + 0x8000000000000000ULL;
  return (unsigned long long) d;
}
#define double2ulonglong my_double2ulonglong
#endif

#ifndef ulonglo other handler error happened */
#define HA_ERR_INITIALIZATION     174    /* Error during initialization */
#define HA_ERR_FILE_TOO_SHORT	  175	 /* File too short */
#define HA_ERR_WRONG_CRC	  176	 /* Wrong CRC on page */
#define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */
/* There's no explicitly listed partition in table for the given value */
#define HA_ERR_NOT_IN_LOCK_PARTITIONS 178
#define HA_ERR_INDEX_COL_TOO_LONG 179    /* Index column length exceeds limit */
#define HA_ERR_INDEX_CORRUPT      180    /* Index corrupted */
#define HA_ERR_UNDO_REC_TOO_BIG   181    /* Undo log record too big */
#define HA_FTS_INVALID_DOCID      182	 /* Invalid InnoDB Doc ID */
/* #define HA_ERR_TABLE_IN_FK_CHECK  183 */ /* Table being used in foreign key check */
#define HA_ERR_TABLESPACE_EXISTS  184    /* The tablespace existed in storage engine */
#define HA_ERR_TOO_MANY_FIELDS    185    /* Table has too many columns */
#define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partitudf_arg, List<Item> &list):
    Item_int_func(thd, list) {}
  const Type_handler *type_handler() const override
  { return &type_handler_slonglong; }
  my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed()); return 0; }
};


class Item_func_udf_str :public Item_func
{
public:
  Item_func_udf_str(THD *thd, udf_func *udf_arg):
    Item_func(thd) {}
  Item_func_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list):
    Item_func(thd, list) {}
  String *val_str(String *)
    { DBUG_ASSERT(fixed()); null_value=1; return 0; }
  double val_real() { DBUG_ASSERT(fixed()); null_value= 1; return 0.0; }
  longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 0; }
  bool fix_length_and_dec(THD *thd) override
  { base_flags|= item_base_t::MAYBE_NULL; max_length=0; return FALSE; }
};

#endif /* HAVE_DLOPEN */

void mysql_ull_cleanup(THD *thd);
void mysql_ull_set_explicit_lock_duration(THD *thd);


class Item_func_lock :public Item_long_func
{
 public:
  Item_func_lock(THD *thd): Item_long_func(thd) { }
  Itm_func_units>(thd, this); }
};


/**
  Item_func_min_max does not derive from Item_func_hybrid_field_type
  because the way how its methods val_xxx() and get_date() work depend
  not only by its arguments, but also on the context in which
  LEAST() and GREATEST() appear.
  For example, using Item_func_min_max in a CAST like this:
    CAST(LEAST('11','2') AS SIGNED)
  forces Item_func_min_max to compare the arguments as numbers rather
  than strings.
  Perhaps this should be changed eventually (see MDEV-5893).
*/
class Item_func_min_max :public Item_hybrid_func
{
  String tmp_value;
  int cmp_sign;
protected:
  bool check_arguments() const override
  {
    return false; // Checked by aggregate_for_min_max()
  }
  bool fix_attributes(Item **item, uint nitems);
public:
  Item_func_min_max(THD *thd, List<Item> &list, int cmp_sign_arg):
    Item_hybrid_func(thd, list), cmp_sign(cmp_sign_arg)
  {}
  String *val_str_native(String *str);
  double val_real_native();
  longlong val_int_native();
  longlong val_uint_natime_args()
  {
    DBUG_ASSERT(fixed());
    for (uint i= 0; i < arg_count; i++)
    {
      if (args[i]->type() == Item::FIELD_ITEM &&
          args[i]->field_type() == MYSQL_TYPE_DATETIME)
        return TRUE;
    }
    return FALSE;
  }

  Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
    override
  {
    /*
      By default only substitution for a field whose two different values
      are never equal is allowed in the arguments of a function.
      This is overruled for the direct arguments of comparison functions.
    */
    Item_args::propagate_equal_fields(thd, Context_identity(), cond);
    return this;
  }

  bool has_rand_bit()
  {
    return used_tables() & RAND_TABLE_BIT;
  }

  bool excl_dep_on_table(table_map tab_map) override
  {
    if (used_tables() & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT))
      return false; 
    return !(used_tables() & ~tab_map) || 
           Item_args::excl_dep_on_table(tab_map);
  }

  bool excl_dep_on_grouping_fields(st_select_lex *sel,
{ ER_XA_RBDEADLOCK                        ,"XA102", "" },
{ ER_FUNC_INEXISTENT_NAME_COLLISION       ,"42000", "" },
{ ER_DUP_SIGNAL_SET                       ,"42000", "" },
{ ER_SIGNAL_WARN                          ,"01000", "" },
{ ER_SIGNAL_NOT_FOUND                     ,"02000", "" },
{ ER_SIGNAL_EXCEPTION                     ,"HY000", "" },
{ ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER      ,"0K000", "" },
{ ER_SPATIAL_MUST_HAVE_GEOM_COL           ,"42000", "" },
{ ER_DATA_OUT_OF_RANGE                    ,"22003", "" },
{ ER_ACCESS_DENIED_NO_PASSWORD_ERROR      ,"28000", "" },
{ ER_TRUNCATE_ILLEGAL_FK                  ,"42000", "" },
{ ER_DA_INVALID_CONDITION_NUMBER          ,"35000", "" },
{ ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO,"23000", "S1009" },
{ ER_FOREIGN_DUPLICATE_KEY_WITHOUT_CHILD_INFO,"23000", "S1009" },
{ ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION,"25006", "" },
{ ER_ALTER_OPERATION_NOT_SUPPORTED        ,"0A000", "" },
{ ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ,"0A000", "" },
{ ER_DUP_UNKNOWN_IN_INDefine SYM(A) SYM_OR_NULL(A),0,&sym_group_common

/*
  Symbols are broken into separated arrays to allow field names with
  same name as functions.
  These are kept sorted for human lookup (the symbols are hashed).

  NOTE! The symbol tables should be the same regardless of what features
  are compiled into the server. Don't add ifdef'ed symbols to the
  lists
  NOTE!!
  If you add or delete symbols from this file, you must also update results for
  the perfschema.start_server_low_digest_sql_length test!
*/

SYMBOL symbols[] = {
  { "&&",		SYM(AND_AND_SYM)},
  { "<=",		SYM(LE)},
  { "<>",		SYM(NE)},
  { "!=",		SYM(NE)},
  { ">=",		SYM(GE)},
  { "<<",		SYM(SHIFT_LEFT)},
  { ">>",		SYM(SHIFT_RIGHT)},
  { "<=>",		SYM(EQUAL_SYM)},
  { "ACCESSIBLE",	SYM(ACCESSIBLE_SYM)},
  { "ACCOUNT",		SYM(ACCOUNT_SYM)},
  { "ACTION",		SYM(ACTION)},
  { "ADD",		SYM(ADD)},
  { "ADMIN",            SYM(ADMIN_SYM)},
  { "AFTER",		SYM(AFTER_SYM)},
  { "AGAINST",          SYM(AGAINST)},
  { "AGGREGATE",	SYM(AGGREGATE_SYM)},
  { "ALL",		_mysql_prlock mysql_prlock_t;

/**
  An instrumented cond structure.
  @sa mysql_cond_t
*/
struct st_mysql_cond
{
  /** The real condition */
  pthread_cond_t m_cond;
  /**
    The instrumentation hook.
    Note that this hook is not conditionally defined,
    for binary compatibility of the @c mysql_cond_t interface.
  */
  struct PSI_cond *m_psi;
};

/**
  Type of an instrumented condition.
  @c mysql_cond_t is a drop-in replacement for @c pthread_cond_t.
  @sa mysql_cond_init
  @sa mysql_cond_wait
  @sa mysql_cond_timedwait
  @sa mysql_cond_signal
  @sa mysql_cond_broadcast
  @sa mysql_cond_destroy
*/
typedef struct st_mysql_cond mysql_cond_t;

/*
  Consider the following code:
    static inline void foo() { bar(); }
  when foo() is never called.

  With gcc, foo() is a local static function, so the dependencies
  are optimized away at compile time, and there is no dependency on bar().
  With other compilers (HP, Sun Studio), the function foo() implementation
  is compiled, and bar() needs to be present toid {
    USE_GTID_NO= 0, USE_GTID_CURRENT_POS= 1, USE_GTID_SLAVE_POS= 2
  };

  Master_info(LEX_CSTRING *connection_name, bool is_slave_recovery);
  ~Master_info();
  bool shall_ignore_server_id(ulong s_id);
  void clear_in_memory_info(bool all);
  bool error()
  {
    /* If malloc() in initialization failed */
    return connection_name.str == 0;
  }
  static const char *using_gtid_astext(enum enum_using_gtid arg);
  bool using_parallel()
  {
    return opt_slave_parallel_threads > 0 &&
      parallel_mode > SLAVE_PARALLEL_NONE;
  }
  void release();
  void wait_until_free();
  void lock_slave_threads();
  void unlock_slave_threads();

  ulonglong get_slave_skip_counter()
  {
    return rli.slave_skip_counter;
  }

  ulonglong get_max_relay_log_size()
  {
    return rli.max_relay_log_size;
  }

  /* the variables below are needed because we can change masters on the fly */
  char master_log_name[FN_REFLEN+6]; /* Room for multi-*/
  char host[HOSTNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
  char user[USERNAME_LEindexes, and
    - another to represent multi-column indexes.
    Such separation would allow slightly more efficient implementation of
    the single-column indexes.
  = The current design requires such indexes to be fully recreated for each
    PS (re)execution, however most of the comprising objects can be reused.
*/

class Ordered_key : public Sql_alloc
{
protected:
  /*
    Index of the key in an array of keys. This index allows to
    construct (sub)sets of keys represented by bitmaps.
  */
  uint keyid;
  /* The table being indexed. */
  TABLE *tbl;
  /* The columns being indexed. */
  Item_field **key_columns;
  /* Number of elements in 'key_columns' (number of key parts). */
  uint key_column_count;
  /*
    An expression, or sequence of expressions that forms the search key.
    The search key is a sequence when it is Item_row. Each element of the
    sequence is accessible via Item::element_index(int i).
  */
  Item *search_key;

/* Value index related members. */
  /*
    The actual value index, cjump_if_not instructions have two different destinations
    which are to be patched differently.
    Since these occur in a more restricted way (always the same "level" in
    the code), we don't need the label.
  */
  List<sp_instr_opt_meta> m_cont_backpatch;
  uint m_cont_level;            // The current cont. backpatch level

  /**
    Multi-set representing optimized list of tables to be locked by this
    routine. Does not include tables which are used by invoked routines.

    @note
    For prelocking-free SPs this multiset is constructed too.
    We do so because the same instance of sp_head may be called both
    in prelocked mode and in non-prelocked mode.
  */
  HASH m_sptabs;

  /**
    Text of the query CREATE PROCEDURE/FUNCTION/TRIGGER/EVENT ...
    used for DDL parsing.
  */
  LEX_STRING m_definition_string;

  bool
  execute(THD *thd, bool merge_da_on_success);

  /**
    Perform a forward flow analysis in the generated code.
    Mark reachable instructions, for the optimizer.
  */
  void opt_*) 0;
    }
  public:
    XML() { reset(); }
    void set_charset(CHARSET_INFO *cs) { m_parsed_buf.set_charset(cs); }
    String *raw() { return m_raw_ptr; }
    String *parsed() { return &m_parsed_buf; }
    const MY_XML_NODE *node(uint idx);
    bool cached() { return m_cached; }
    bool parse(String *raw, bool cache);
    bool parse(Item *item, bool cache)
    {
      String *res;
      if (!(res= item->val_str(&m_raw_buf)))
      {
        m_raw_ptr= (String *) 0;
        m_cached= cache;
        return true;
      }
      return parse(res, cache);
    }
  };
  String m_xpath_query; // XPath query text
  Item *nodeset_func;
  XML xml;
  bool get_xml(XML *xml_arg, bool cache= false)
  {
    if (!cache && xml_arg->cached())
      return xml_arg->raw() == 0;
    return xml_arg->parse(args[0], cache);
  }
public:
  Item_xml_str_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b)
  {
    set_maybe_null();
  }
  Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c):
    Item_str_func(thd, a, b, c)
  {
 doesn't exist
  - The invoker without MISSING_DEFINER_ACL gets a generic access error,
    without revealing details that the definer does not exists.

  TODO: we should eventually test the same privilege when processing
  other objects that have the DEFINER clause (e.g. routines, triggers).
  Currently the missing definer is revealed for non-privileged invokers
  in case of routines, triggers, etc.

  Was SUPER prior to 10.5.2
*/
constexpr privilege_t PRIV_REVEAL_MISSING_DEFINER= SET_USER_ACL;

/* Actions that require only the SUPER privilege */
constexpr privilege_t PRIV_DES_DECRYPT_ONE_ARG= SUPER_ACL;
constexpr privilege_t PRIV_LOG_BIN_TRUSTED_SP_CREATOR= SUPER_ACL;
constexpr privilege_t PRIV_DEBUG= SUPER_ACL;
constexpr privilege_t PRIV_SET_GLOBAL_SYSTEM_VARIABLE= SUPER_ACL;
constexpr privilege_t PRIV_SET_RESTRICTED_SESSION_SYSTEM_VARIABLE= SUPER_ACL;

/* The following variables respected only SUPER_ACL prior to 10.5.2 */
constexpr privilege_t PRIV_SET_SYSTEM_VAR_BINLOG_FORMAT=
  BINLOG_ADMIN_ACL;

consteram is also distributed with certain software (including
  but not limited to OpenSSL) that is licensed under separate terms,
  as designated in a particular file or component or in included license
  documentation.  The authors of MySQL hereby grant you an additional
  permission to link the program and your derivative works with the
  separately licensed software that they have included with MySQL.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License, version 2.0, for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */

/**
  @file mysql/psi/psi_abi_v0.h
  ABI check for mysql/psi/psi.h, when compiling without instrumentation.
  This file is only used to automate detection 
  /* Set to true if this is a recursive element with an anchor */ 
  bool with_anchor;
  /* 
    Set to the first recursive select of the unit specifying the element
    after all anchor have been moved to the head of the unit.
  */
  st_select_lex *first_recursive;
  
  /* 
    The number of the last performed iteration for recursive table
    (the number of the initial non-recursive step is 0, the number
     of the first iteration is 1).
  */
  uint level;

  /* 
    The pointer to the object used to materialize this with element
    if it's recursive. This object is built at the end of prepare 
    stage and is used at the execution stage.
  */
  select_union_recursive *rec_result;

  /* List of Item_subselects containing recursive references to this CTE */
  SQL_I_List<Item_subselect> sq_with_rec_ref;
  /* List of derived tables containing recursive references to this CTE */
  SQL_I_List<TABLE_LIST> derived_with_rec_ref;

  With_element(With_element_head *h,
               List <Lex_ident_sys> list,
    semi-join */
  };

  virtual enum explain_node_type get_type()= 0;
  virtual uint get_select_id()= 0;

  /**
    expression cache statistics
  */
  Expression_cache_tracker* cache_tracker;

  /**
    If not NULL, this node is a SELECT (or UNION) in a materialized
    IN-subquery.
  */
  Explain_subq_materialization* subq_materialization;

  /*
    How this node is connected to its parent.
    (NOTE: EXPLAIN_NODE_NON_MERGED_SJ is set very late currently)
  */
  enum explain_connection_type connection_type;

protected:
  /* 
    A node may have children nodes. When a node's explain structure is 
    created, children nodes may not yet have QPFs. This is why we store ids.
  */
  Dynamic_array<int> children;
public:
  void add_child(int select_no)
  {
    children.append(select_no);
  }

  virtual int print_explain(Explain_query *query, select_result_sink *output, 
                            uint8 explain_flags, bool is_analyze)=0;
  virtual void print_explain_json(Explain_query *query, Json_writer *writer, 
   int make_compatible_event(String *packet, bool *need_dummy_event,
                                    ulong ev_offset, enum_binlog_checksum_alg checksum_alg);
  static bool peek(const uchar *event_start, size_t event_len,
                   enum_binlog_checksum_alg checksum_alg,
                   uint32 *domain_id, uint32 *server_id, uint64 *seq_no,
                   uchar *flags2, const Format_description_log_event *fdev);
#endif
};


/**
  @class Gtid_list_log_event

  This event is logged at the start of every binlog file to record the
  current replication state: the last global transaction id (GTID) applied
  on the server within each replication domain.

  It consists of a list of GTIDs, one for each replication domain ever seen
  on the server.

  @section Gtid_list_log_event_binary_format Binary Format

  <table>
  <caption>Post-Header</caption>

  <tr>
    <th>Name</th>
    <th>Format</th>
    <th>Description</th>
  </tr>

  <tr>
    <td>count</td>
    <td>4 byte unsigned integer</td>
    <td>The arg)
  {
    if (direct)
      cache_type= Log_event::EVENT_NO_CACHE;
  }
#ifdef HAVE_REPLICATION
  void pack_info(Protocol* protocol) override;
#endif /* HAVE_REPLICATION */
#else
  bool print(FILE* file, PRINT_EVENT_INFO* print_event_info) override;
#endif

  Rand_log_event(const uchar *buf,
                 const Format_description_log_event *description_event);
  ~Rand_log_event() = default;
  Log_event_type get_type_code() override { return RAND_EVENT;}
  int get_data_size() override { return 16; /* sizeof(ulonglong) * 2*/ }
#ifdef MYSQL_SERVER
  bool write(Log_event_writer *writer) override;
#ifdef HAVE_REPLICATION
   bool is_part_of_group() override { return 1; }
#endif
#endif
  bool is_valid() const override { return 1; }

private:
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
  int do_apply_event(rpl_group_info *rgi) override;
  int do_update_pos(rpl_group_info *rgi) override;
  enum_skip_reason do_shall_skip(rpl_group_info *rgi) override;
#endif
};


class Xid_apply_log_event: public Log_evtes
    from the beginning of the file.  In a relay log, this is
    the position of the next event in the master's binlog.
    </td>
  </tr>

  <tr>
    <td>flags</td>
    <td>2 byte bitfield</td>
    <td>See Log_event::flags.</td>
  </tr>
  </table>

  Summing up the numbers above, we see that the total size of the
  common header is 19 bytes.

  @subsection Log_event_format_of_atomic_primitives Format of Atomic Primitives

  - All numbers, whether they are 16-, 24-, 32-, or 64-bit numbers,
  are stored in little endian, i.e., the least significant byte first,
  unless otherwise specified.

  @anchor packed_integer
  - Some events use a special format for efficient representation of
  unsigned integers, called Packed Integer.  A Packed Integer has the
  capacity of storing up to 8-byte integers, while small integers
  still can use 1, 3, or 4 bytes.  The value of the first byte
  determines how to read the number, according to the following table:

  <table>
  <caption>Format of Packed Integer</caption>

   Charset_collation_map_st::binary_size_max() \
                                   /* type, map */ \
                                   )
#define MAX_LOG_EVENT_HEADER   ( /* in order of Query_log_event::write */ \
  LOG_EVENT_HEADER_LEN + /* write_header */ \
  QUERY_HEADER_LEN     + /* write_data */   \
  EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN + /*write_post_header_for_derived */ \
  MAX_SIZE_LOG_EVENT_STATUS + /* status */ \
  NAME_LEN + 1)

/*
  The new option is added to handle large packets that are sent from the master 
  to the slave. It is used to increase the thd(max_allowed) for both the
  DUMP thread on the master and the SQL/IO thread on the slave. 
*/
#define MAX_MAX_ALLOWED_PACKET (1024*1024*1024)

/* 
   Event header offsets; 
   these point to places inside the fixed header.
*/

#define EVENT_TYPE_OFFSET    4
#define SERVER_ID_OFFSET     5
#define EVENT_LEN_OFFSET     9
#define LOG_POS_OFFSET       13
#define FLAGS_OFFSET         17

/* start event post-header (for v3 and v4) */

#define ST_BINLOG}
    virtual void set_dependents(Json_schema_keyword *schema1,
                                Json_schema_keyword *schema2)
    {
      return;
    }
};

/*
  Additional and unvaluated keywords and items handle
  keywords and validate schema in same way, so it makes sense
  to have a base class for them.
*/
class Json_schema_additional_and_unevaluated : public Json_schema_keyword
{
  public:
    List<Json_schema_keyword> schema_list;
    Json_schema_additional_and_unevaluated()
    {
      allowed= true;
    }
    void set_allowed(bool allowed_val)
    {
      allowed= allowed_val;
    }
    bool handle_keyword(THD *thd, json_engine_t *je,
                        const char* key_start,
                        const char* key_end,
                        List<Json_schema_keyword> *all_keywords) override;
    bool validate(const json_engine_t *je,
                  const uchar *k_start= NULL,
                  const uchar *k_end= NULL) override
    {
      return false;
    }
    bool validate_as_alternate(coFILE__,__LINE__)
#define my_cond_wait(A,B) safe_cond_wait((A), (B), __FILE__, __LINE__)
#else

#define safe_mutex_is_owner(mp) (1)
#define safe_mutex_assert_owner(mp) do {} while (0)
#define safe_mutex_assert_not_owner(mp) do {} while (0)
#define safe_mutex_setflags(mp, F) do {} while (0)

#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A),(B),(C))
#define my_cond_wait(A,B) pthread_cond_wait((A), (B))
#endif /* !SAFE_MUTEX */

	/* READ-WRITE thread locking */

#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
/* use these defs for simple mutex locking */
#define rw_lock_t pthread_mutex_t
#define my_rwlock_init(A,B) pthread_mutex_init((A),(B))
#define rw_rdlock(A) pthread_mutex_lock((A))
#define rw_wrlock(A) pthread_mutex_lock((A))
#define rw_tryrdlock(A) pthread_mutex_trylock((A))
#define rw_trywrlock(A) pthread_mutex_trylock((A))
#define rw_unlock(A) pthread_mutex_unlock((A))
#define rwlock_destroy(A) pthread_mutex_destroy((A))
#elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
#define rw_lock_t pthread_rwlock_t
#dcket instrumentation end event.
  Note that for socket close operations, the instrumented socket handle
  associated with the socket (which was provided to obtain a locker)
  is invalid after this call.
  @param locker a socket locker for the running thread
  @param count the number of bytes actually used in the operation,
  or 0 if not applicable, or -1 if the operation failed
  @sa get_thread_socket_locker
*/
typedef void (*end_socket_wait_v1_t)
  (struct PSI_socket_locker *locker, size_t count);

/**
  Set the socket state for an instrumented socket.
    @param socket the instrumented socket
    @param state socket state
  */
typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
                                      enum PSI_socket_state state);

/**
  Set the socket info for an instrumented socket.
  @param socket the instrumented socket
  @param fd the socket descriptor
  @param addr the socket ip address
  @param addr_len length of socket ip address
  @param thread_id associated thread id
*/
 the file after rename.
  @param rc the rename operation return code (0 for success).
*/
typedef void (*end_file_rename_wait_v1_t)
  (struct PSI_file_locker *locker, const char *old_name,
   const char *new_name, int rc);

/**
  Start a new stage, and implicitly end the previous stage.
  @param key the key of the new stage
  @param src_file the source file name
  @param src_line the source line number
  @return the new stage progress
*/
typedef PSI_stage_progress* (*start_stage_v1_t)
  (PSI_stage_key key, const char *src_file, int src_line);

typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);

/** End the current stage. */
typedef void (*end_stage_v1_t) (void);

/**
  Get a statement instrumentation locker.
  @param state data storage for the locker
  @param key the statement instrumentation key
  @param charset client character set
  @return a statement locker, or NULL
*/
typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
  (struct PSI_statement_locker_state_v1 *statew delete. */
  PSI_TABLE_DELETE_ROW= 3
};
typedef enum PSI_table_io_operation PSI_table_io_operation;

/**
  State data storage for @c start_table_io_wait_v1_t,
  @c start_table_lock_wait_v1_t.
  This structure provide temporary storage to a table locker.
  The content of this structure is considered opaque,
  the fields are only hints of what an implementation
  of the psi interface can use.
  This memory is provided by the instrumented code for performance reasons.
  @sa start_table_io_wait_v1_t
  @sa start_table_lock_wait_v1_t
*/
struct PSI_table_locker_state
{
  /** Internal state. */
  uint m_flags;
  /** Current io operation. */
  enum PSI_table_io_operation m_io_operation;
  /** Current table handle. */
  struct PSI_table *m_table;
  /** Current table share. */
  struct PSI_table_share *m_table_share;
  /** Current thread. */
  struct PSI_thread *m_thread;
  /** Timer start. */
  ulonglong m_timer_start;
  /** Timer function. */
  ulonglong (*m_timer)(void);
  /** Internal data. */
  void *m_wait;
  /*(A) PSI_METADATA_CALL(destroy_metadata_lock)(A)
#else
#define PSI_CALL_start_metadata_wait(A,B,C,D) 0
#define PSI_CALL_end_metadata_wait(A,B) do { } while(0)
#define PSI_CALL_create_metadata_lock(A,B,C,D,E,F,G) 0
#define PSI_CALL_set_metadata_lock_status(A,B) do {} while(0)
#define PSI_CALL_destroy_metadata_lock(A) do {} while(0)
#endif

/**
  @defgroup Thread_instrumentation Metadata Instrumentation
  @ingroup Instrumentation_interface
  @{
*/

/**
  @def mysql_mdl_create(K, M, A)
  Instrumented metadata lock creation.
  @param I Metadata lock identity
  @param K Metadata key
  @param T Metadata lock type
  @param D Metadata lock duration
  @param S Metadata lock status
  @param F request source file
  @param L request source line
*/

#ifdef HAVE_PSI_METADATA_INTERFACE
  #define mysql_mdl_create(I, K, T, D, S, F, L) \
    inline_mysql_mdl_create(I, K, T, D, S, F, L)
#else
  #define mysql_mdl_create(I, K, T, D, S, F, L) NULL
#endif

#ifdef HAVE_PSI_METADATA_INTERFACE
  #define mysql_mdl_set_status(L, S) \
   ferent threads.
            In practice, this is not necessary as code which reads this
            value and so might miss the fact that value was changed will
            always re-try reading it after small timeout and therefore
            will see the new value eventually.
    */
    m_needs_thr_lock_abort= needs_thr_lock_abort;
  }
  bool get_needs_thr_lock_abort() const
  {
    return m_needs_thr_lock_abort;
  }
public:
  /**
    If our request for a lock is scheduled, or aborted by the deadlock
    detector, the result is recorded in this class.
  */
  MDL_wait m_wait;
private:
  /**
    Lists of all MDL tickets acquired by this connection.

    Lists of MDL tickets:
    ---------------------
    The entire set of locks acquired by a connection can be separated
    in three subsets according to their duration: locks released at
    the end of statement, at the end of transaction and locks are
    released explicitly.

    Statement and transactional locks are locks with automatic scope.
    They are a}
  enum_sql_command sqlcom_create() const override
  {
    return SQLCOM_CREATE_FUNCTION;
  }
  enum_sql_command sqlcom_drop() const override
  {
    return SQLCOM_DROP_FUNCTION;
  }
  LEX_CSTRING empty_body_lex_cstring(sql_mode_t mode) const override;
  const char *show_create_routine_col1_caption() const override
  {
    return "Function";
  }
  const char *show_create_routine_col3_caption() const override
  {
    return "Create Function";
  }
  MDL_key::enum_mdl_namespace get_mdl_type() const override
  {
    return MDL_key::FUNCTION;
  }
  const Sp_handler *package_routine_handler() const override;
  sp_cache **get_cache(THD *) const override;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
  HASH *get_priv_hash() const override;
#endif
  bool add_instr_freturn(THD *thd, sp_head *sp, sp_pcontext *spcont,
                         Item *item, sp_expr_lex *lex) const override;
};


class Sp_handler_package_function: public Sp_handler_function
{
public:
  int sp_cache_routine(THD *thd, const Database_qualified_name *name,_DEF_QUERY_HASH_SIZE,
	      uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);

  inline bool is_disabled(void) { return m_cache_status != OK; }
  inline bool is_disable_in_progress(void)
  { return m_cache_status == DISABLE_REQUEST; }

  /* initialize cache (mutex) */
  void init();
  /* resize query cache (return real query size, 0 if disabled) */
  size_t resize(size_t query_cache_size);
  /* set limit on result size */
  inline void result_size_limit(size_t limit){query_cache_limit=limit;}
  /* set minimal result data allocation unit size */
  size_t set_min_res_unit(size_t size);

  /* register query in cache */
  void store_query(THD *thd, TABLE_LIST *used_tables);

  /*
    Check if the query is in the cache and if this is true send the
    data to client.
  */
  int send_result_to_client(THD *thd, char *query, uint query_length);

  /* Remove all queries that uses any of the listed following tables */
  void invalidate(THD *thd, TABLE_LIST *tables_used,
		  my_bool using_transactions);
  vo{ "ER_WARN_TRIGGER_DOESNT_HAVE_CREATED", 3010, "Trigger %s.%s.%s does not have CREATED attribute." },
{ "ER_REFERENCED_TRG_DOES_NOT_EXIST_MYSQL", 3011, "Referenced trigger \'%s\' for the given action time and event type does not exist." },
{ "ER_EXPLAIN_NOT_SUPPORTED", 3012, "EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE" },
{ "ER_INVALID_FIELD_SIZE", 3013, "Invalid size for column \'%-.192s\'." },
{ "ER_MISSING_HA_CREATE_OPTION", 3014, "Table storage engine \'%-.64s\' found required create option missing" },
{ "ER_ENGINE_OUT_OF_MEMORY", 3015, "Out of memory in storage engine \'%-.64s\'." },
{ "ER_PASSWORD_EXPIRE_ANONYMOUS_USER", 3016, "The password for anonymous user cannot be expired." },
{ "ER_SLAVE_SQL_THREAD_MUST_STOP", 3017, "This operation cannot be performed with a running slave sql thread; run STOP SLAVE SQL_THREAD first" },
{ "ER_NO_FT_MATERIALIZED_SUBQUERY", 3018, "Cannot create FULLTEXT index on materialized subquery" },
{ "ER_INNODB_UNDO_LOG_FULL", 3019, "CREATE TABLE... SELECT...  on a table with an auto-increment column is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are inserted. This order cannot be predicted and may differ on master and the slave" },
{ "ER_BINLOG_UNSAFE_INSERT_TWO_KEYS", 1724, "INSERT... ON DUPLICATE KEY UPDATE  on a table with more than one UNIQUE KEY is unsafe" },
{ "ER_UNUSED_28", 1725, "You should never see it" },
{ "ER_VERS_NOT_ALLOWED", 1726, "Not allowed for system-versioned table %sQ.%sQ" },
{ "ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST", 1727, "INSERT into autoincrement field which is not the first part in the composed primary key is unsafe" },
{ "ER_CANNOT_LOAD_FROM_TABLE_V2", 1728, "Cannot load from %s.%s. The table is probably corrupted" },
{ "ER_MASTER_DELAY_VALUE_OUT_OF_RANGE", 1729, "The requested value %lu for the master delay exceeds the maximum %lu" },
{ "ER_ONLY_FD_AND_RBR_EVENTS_ALLOWED_IN_BINLOG_STATEMENT", 1730, "Only Format_description_log_event and row events are allowof the row-based binary log format when the session has open temporary tables" },
{ "ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT", 1560, "Cannot change the binary logging format inside a stored function or trigger" },
{ "ER_UNUSED_13", 1561, "You should never see it" },
{ "ER_PARTITION_NO_TEMPORARY", 1562, "Cannot create temporary table with partitions" },
{ "ER_PARTITION_CONST_DOMAIN_ERROR", 1563, "Partition constant is out of partition function domain" },
{ "ER_PARTITION_FUNCTION_IS_NOT_ALLOWED", 1564, "This partition function is not allowed" },
{ "ER_DDL_LOG_ERROR", 1565, "Error in DDL log" },
{ "ER_NULL_IN_VALUES_LESS_THAN", 1566, "Not allowed to use NULL value in VALUES LESS THAN" },
{ "ER_WRONG_PARTITION_NAME", 1567, "Incorrect partition name" },
{ "ER_CANT_CHANGE_TX_CHARACTERISTICS", 1568, "Transaction characteristics can\'t be changed while a transaction is in progress" },
{ "ER_DUP_ENTRY_AUTOINCREMENT_CASE", 1569, "ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry \'%-
{ "ER_BLOB_KEY_WITHOUT_LENGTH", 1170, "BLOB/TEXT column \'%-.192s\' used in key specification without a key length" },
{ "ER_PRIMARY_CANT_HAVE_NULL", 1171, "All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead" },
{ "ER_TOO_MANY_ROWS", 1172, "Result consisted of more than one row" },
{ "ER_REQUIRES_PRIMARY_KEY", 1173, "This table type requires a primary key" },
{ "ER_NO_RAID_COMPILED", 1174, "This version of MariaDB is not compiled with RAID support" },
{ "ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE", 1175, "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column" },
{ "ER_KEY_DOES_NOT_EXISTS", 1176, "Key \'%-.192s\' doesn\'t exist in table \'%-.192s\'" },
{ "ER_CHECK_NO_SUCH_TABLE", 1177, "Can\'t open table" },
{ "ER_CHECK_NOT_IMPLEMENTED", 1178, "The storage engine for the table doesn\'t support %s" },
{ "ER_CANT_DO_THIS_DURING_AN_TRANSACTION", 1179, "You are not allowed to execute this command in a transaction" },
{ "ER_ERROR_DURINerived;

  /*
    Temporary table where all results should be stored in record[0]
    The table has a field for every item from the select list of
    the specification of derived.
  */
  TABLE *table;

  /* The parameters if the temporary table used at its creation */
  TMP_TABLE_PARAM *tmp_table_param;

  SELECT_LEX_UNIT *unit;   // Specifies the derived table

  SELECT_LEX *select;      // The first select of the specification

  derived_handler(THD *thd_arg, handlerton *ht_arg)
    : thd(thd_arg), ht(ht_arg), derived(0),table(0), tmp_table_param(0),
    unit(0), select(0) {}
  virtual ~derived_handler() = default;

  /*
    Functions to scan data. All these returns 0 if ok, error code in case
    of error
  */

  /* Initialize the process of producing rows of the derived table */
  virtual int init_scan()= 0;

  /*
    Put the next produced row of the derived in table->record[0] and return 0.
    Return HA_ERR_END_OF_FILE if there are no more rows, return other error
    number in case of fatal error.
        thd->security_ctx->host, thd->security_ctx->ip, thd->query_id,
      share, lock);
}

static inline
void mysql_audit_create_table(TABLE *table)
{
  if (mysql_audit_table_enabled())
  {
    THD *thd= table->in_use;
    const TABLE_SHARE *share= table->s;
    const Security_context *sctx= thd->security_ctx;
    mysql_event_table event;

    event.event_subclass= MYSQL_AUDIT_TABLE_CREATE;
    event.read_only= 0;
    event.thread_id= (unsigned long)thd->thread_id;
    event.user= sctx->user;
    event.priv_user= sctx->priv_user;
    event.priv_host= sctx->priv_host;
    event.external_user= sctx->external_user;
    event.proxy_user= sctx->proxy_user;
    event.host= sctx->host;
    event.ip= sctx->ip;
    event.database=     share->db;
    event.table=        share->table_name;
    event.new_database= null_clex_str;
    event.new_table=    null_clex_str;
    event.query_id=     thd->query_id;

    mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
  }
}

static inline
void mysql_audit_drop_table(THD *u.lto_.ext_symtab.25c12d54638e3cd4 .gnu.lto_.opts .comment .note.GNU-stack .note.gnu.property                                                                                         @                                      !                     @                                      '                     @                                      ,         €            @                                     O         €            O                                     n         €            h                                     ‘         €            y                                     ³         €            Š                                     ×         €            ›                                     ü         €            ©                                     "        €            º                                     A        €            Â                                     i        €            Ú                                     ‰        €            è            1795707564  0     0     100644  2976      `
ELF          >                               @     @   (µ/ý 1       (µ/ý …  P  ´Ÿ�Ï  À(µ/ý E    À(µ/ý E    À(µ/ý E    À(µ/ý )      (µ/ý E    À     (µ/ý y        �¤    (µ/ý )      (µ/ý`/ % Ô
N   Á      ÿÿÿÿ   Ý   Â   î € À  7€¡; Á   ¯‡ê«-Ø�€ø­�Ò¤’€ î ¾ÂÀ¿  ¾¼  encryption_scheme_serviceM/build/pkg/net/mariadb-11.8.3/libs/.cGNU C99 N  ªšž°0UÙ¹:KEwƒYencryption_scheme_service            Â    '-fno-openmp' '-fno-openacc' '-fcf-protection=none' '-mtune=generic' '-march=x86-64' '-O3' '-O3' '-Wno-error=coverage-mismatch' '-Wno-error=missing-profile' '-flto' '-fprofile-use=/tmp/pgo-mariadb' '-fprofile-correction' '-fstack-protector' '-fPIC' '--param=ssp-buffer-size=4'  GCC: (GNU) 16.2.0                 GNU  À            À                                      òÿ               __gnu_lto_slim  .symtab .strtab .shstrtab .text .data .bss .gnu.lto_.profile.e6a8e92f9965984  */

#include "my_base.h"                            /* ha_rows */
#include <my_cmp.h>
#include "queues.h"
#include "sql_string.h"
#include "sql_class.h"

class Field;
struct TABLE;

/* Defines used by filesort and uniques */

#define MERGEBUFF		7
#define MERGEBUFF2		15

/*
   The structure SORT_ADDON_FIELD describes a fixed layout
   for field values appended to sorted values in records to be sorted
   in the sort buffer.
   Only fixed layout is supported now.
   Null bit maps for the appended values is placed before the values 
   themselves. Offsets are from the last sorted field, that is from the
   record referefence, which is still last component of sorted records.
   It is preserved for backward compatiblility.
   The structure is used tp store values of the additional fields 
   in the sort buffer. It is used also when these values are read
   from a temporary file/buffer. As the reading procedures are beyond the
   scope of the 'filesort' code the values have to be retrieved via
   the callback funct a drop-in replacement for @c FILE.
  @sa mysql_file_open
*/
typedef struct st_mysql_file MYSQL_FILE;

static inline void inline_mysql_file_register(
#ifdef HAVE_PSI_FILE_INTERFACE
  const char *category,
  PSI_file_info *info,
  int count
#else
  const char *category __attribute__ ((unused)),
  void *info __attribute__ ((unused)),
  int count __attribute__ ((unused))
#endif
)
{
#ifdef HAVE_PSI_FILE_INTERFACE
  PSI_FILE_CALL(register_file)(category, info, count);
#endif
}

static inline char *
inline_mysql_file_fgets(
#ifdef HAVE_PSI_FILE_INTERFACE
  const char *src_file, uint src_line,
#endif
  char *str, int size, MYSQL_FILE *file)
{
  char *result;
#ifdef HAVE_PSI_FILE_INTERFACE
  if (psi_likely(file->m_psi))
  {
    struct PSI_file_locker *locker;
    PSI_file_locker_state state;
    locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_READ);
    if (likely(locker != NULL))
    {
      PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line);
      result= fG connection_cl_name;
  LEX_CSTRING db_cl_name;

  GRANT_INFO subject_table_grants;
  sql_mode_t sql_mode;
  /* Store create time. Can't be mysql_time_t as this holds also sub seconds */
  my_hrtime_t hr_create_time; // Create time timestamp in microseconds
  trg_event_type event;
  trg_action_time_type action_time;
  uint action_order;
  List<LEX_CSTRING> *updatable_columns;

  void get_trigger_info(LEX_CSTRING *stmt, LEX_CSTRING *body,
                        LEX_STRING *definer);
  /* Functions executed over each active trigger */
  bool change_on_table_name(void* param_arg);
  bool change_table_name(void* param_arg);
  bool add_to_file_list(void* param_arg);

  bool match_updatable_columns(List<Item> &fields);
};

typedef bool (Trigger::*Triggers_processor)(void *arg);

/**
  This class holds all information about triggers of table.
*/

class Table_triggers_list: public Sql_alloc
{
  friend class Trigger;

  /* Points to first trigger for a certain type */
  Trigger *triggers[TRG_EVENT_MAX][TRG_ACTION_MAXlic License
  along with this program; if not, write to the Free Software Foundation,
  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */

#ifndef PFS_FILE_PROVIDER_H
#define PFS_FILE_PROVIDER_H

/**
  @file include/pfs_file_provider.h
  Performance schema instrumentation (declarations).
*/

#ifdef HAVE_PSI_FILE_INTERFACE
#ifdef MYSQL_SERVER
#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_DYNAMIC_PLUGIN

#include "mysql/psi/psi.h"

#define PSI_FILE_CALL(M) pfs_ ## M ## _v1

C_MODE_START

void pfs_register_file_v1(const char *category,
                          PSI_file_info_v1 *info,
                          int count);

void pfs_create_file_v1(PSI_file_key key, const char *name, File file);

PSI_file_locker*
pfs_get_thread_file_name_locker_v1(PSI_file_locker_state *state,
                                   PSI_file_key key,
                                   PSI_file_operation op,
                                   const char *name, const void *identity);

PSI_file_locker*
pfs_get_thread_file_stream_lockerned_flag for numeric fields
    - charset() for string fields
    - typelib and field_length for SET and ENUM
    - geom_type and srid for GEOMETRY
    This information is not available in the binary log, so
    we assume that these fields are the same on the master and on the slave.
  */
  virtual Field *make_conversion_table_field(MEM_ROOT *root,
                                             TABLE *table,
                                             uint metadata,
                                             const Field *target) const= 0;
  virtual void show_binlog_type(const Conv_source &src, const Field &dst,
                                String *str) const;
  virtual uint32 max_display_length_for_field(const Conv_source &src) const= 0;
  /*
    Performs the final data type validation for a UNION element,
    after the regular "aggregation for result" was done.
  */
  virtual bool union_element_finalize(Item_type_holder* item) const
  {
    return false;
  }

  virtual Log_event_data_type user_var_log_ev to_longlong();
  }
  String *to_string(String *str) const
  {
    if (!is_valid_date())
      return NULL;
    str->set_charset(&my_charset_numeric);
    if (!str->alloc(MAX_DATE_STRING_REP_LENGTH))
      str->length(my_date_to_str(this, const_cast<char*>(str->ptr())));
    return str;
  }
  my_decimal *to_decimal(my_decimal *to) const
  {
    return is_valid_date() ? Temporal::to_decimal(to) : bad_to_decimal(to);
  }
};


/**
  Class Datetime is designed to store valid DATETIME values.
  All constructors and modification methods leave instances
  of this class in one of the following valid states:
    a. MYSQL_TIMESTAMP_DATETIME - a DATETIME with all members properly set
    b. MYSQL_TIMESTAMP_NONE     - an undefined value.
  Other MYSQL_TIMESTAMP_XXX are not possible.
  MYSQL_TIMESTAMP_DATETIME with MYSQL_TIME members
  improperly set is not possible.
*/
class Datetime: public Temporal_with_date
{
  bool is_valid_value_slow() const
  {
    return time_type == MYSQL_TIMESTAMP_NONE || is_valid_datetime_slow(char *table_name,
                                       const char *field_name,
                                       const char *value);
  /*
    This method is used if the item was not null but convertion to
    TIME/DATE/DATETIME failed. We return a zero date if allowed,
    otherwise - null.
  */
  void make_fuzzy_date(int *warn, date_conv_mode_t fuzzydate)
  {
    /*
      In the following scenario:
      - The caller expected to get a TIME value
      - Item returned a not NULL string or numeric value
      - But then conversion from string or number to TIME failed
      we need to change the default time_type from MYSQL_TIMESTAMP_DATE
      (which was set in bzero) to MYSQL_TIMESTAMP_TIME and therefore
      return TIME'00:00:00' rather than DATE'0000-00-00'.
      If we don't do this, methods like Item::get_time_with_conversion()
      will erroneously subtract CURRENT_DATE from '0000-00-00 00:00:00'
      and return TIME'-838:59:59' instead of TIME'00:00:00' as a result.
    */
    timestamp_type t<tcpd.h>
#include <syslog.h>
#ifdef NEED_SYS_SYSLOG_H
#include <sys/syslog.h>
#endif /* NEED_SYS_SYSLOG_H */

extern void my_fromhost(struct request_info *req);
extern int my_hosts_access(struct request_info *req);
extern char *my_eval_client(struct request_info *req);

#endif /* HAVE_LIBWRAP */
#endif /* MY_LIBWRAP_INCLUDED */
#include "my_net.h"

struct proxy_peer_info
{
  struct sockaddr_storage peer_addr;
  int port;
  bool is_local_command;
};

extern bool has_proxy_protocol_header(NET *net);
extern int parse_proxy_protocol_header(NET *net, proxy_peer_info *peer_info);
extern bool is_proxy_protocol_allowed(const sockaddr *remote_addr);

extern int init_proxy_protocol_networks(const char *spec);
extern void destroy_proxy_protocol_networks();

extern int  set_proxy_protocol_networks(const char *spec);
extern bool proxy_protocol_networks_valid(const char *spec);

#ifndef SESSION_TRACKER_INCLUDED
#define SESSION_TRACKER_INCLUDED

/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   Co(this, str, end, nchars, status);
  }

  size_t copy_fix(char *dst, size_t dst_length,
                  const char *src, size_t src_length,
                  size_t nchars, MY_STRCOPY_STATUS *status) const
  {
    return (cset->copy_fix)(this, dst, dst_length, src, src_length, nchars,
                          status);
  }

  /* Collation routines */
  uint default_flag() const
  {
    return state & MY_CS_PRIMARY;
  }

  uint binsort_flag() const
  {
    return state & MY_CS_BINSORT;
  }

  uint compiled_flag() const
  {
    return state & MY_CS_COMPILED;
  }

  /*
    Compare two strings for equality.
    There may be a separate more optimized virtual function streq() in
    MY_COLLATION_HANDLER eventually. For now it's a wrapper for strnncoll().
  */
  my_bool streq(const LEX_CSTRING a, const LEX_CSTRING b) const
  {
    return 0 == strnncoll(a, b, FALSE);
  }

  int strnncoll(const LEX_CSTRING a, const LEX_CSTRING b,
                my_bool b_is_prefix= FALSE) const
  {
    DBUG_ASSERT(is_valid_string(a)g will be given.
      5. Cache will be reset for any updates.

  CACHE RULES:
    SEQUENCE class is used to cache values that sequence defined.
      1. If hit cache, we can query back the sequence nextval directly
         instead of reading the underlying table.

      2. When run out of values, the sequence engine will reserve new values
         in update the base table.

      3. The cache is invalidated if any update on based table.
*/

class ha_sequence :public handler
{
private:
  handler *file;
  SEQUENCE *sequence;                     /* From table_share->sequence */

public:
  /* Set when handler is write locked */
  bool write_locked;

  ha_sequence(handlerton *hton, TABLE_SHARE *share);
  ~ha_sequence();
  virtual handlerton *storage_ht() const override
  { return file->ht; }

  /* virtual function that are re-implemented for sequence */
  int open(const char *name, int mode, uint test_if_locked) override;
  int create(const char *name, TABLE *form,
             HA_CREATE_INFO *create_info) overcreating sequence is TOI or RSU,
  CREATE SEQUENCE = CREATE + INSERT (initial value)
  and replicated using statement based replication, thus
  the commit hooks will be skipped.

  For TEMPORARY SEQUENCES commit hooks will be done as
  CREATE + INSERT is not replicated and needs to be
  committed locally. */
  if (ret &&
      (thd->wsrep_cs().mode() == wsrep::client_state::m_toi ||
       thd->wsrep_cs().mode() == wsrep::client_state::m_rsu) &&
      thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE &&
      !thd->lex->tmp_table())
    ret= false;
  mysql_mutex_unlock(&thd->LOCK_thd_data);

  DBUG_PRINT("wsrep", ("return: %d", ret));
  DBUG_RETURN(ret);
}

/*
  Called before the transaction is prepared.

  Return zero on succes, non-zero on failure.
 */
static inline int wsrep_before_prepare(THD* thd, bool all)
{
  DBUG_ENTER("wsrep_before_prepare");
  WSREP_DEBUG("wsrep_before_prepare: %d", wsrep_is_real(thd, all));
  int ret= 0;
  DBUG_ASSERT(wsrep_run_commit_hook(thd, all));
  if ((ret= thd->wsrep_parallel_tring:
        public Item_handled_func::Handler_temporal_string,
        public Func_handler_date_add_interval
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    uint dec= MY_MAX(item->arguments()[0]->datetime_precision(current_thd),
                     interval_dec(item->arguments()[1], int_type(item)));
    item->Type_std_attributes::set(
      Type_temporal_attributes_not_fixed_dec(MAX_DATETIME_WIDTH, dec, false),
      DTCollation(item->default_charset(),
                  DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII));
    item->fix_char_length(item->max_length);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    if (item->arguments()[0]->
          get_date(thd, to, Datetime::Options(TIME_CONV_NONE, thd)) ||
        (to->time_type != MYSQL_TIMESTAMP_TIME &&
         check_date_with_warn(thd, to, TIME_NO_ZEROS, MYSQL_TIMESTAMP_ERROR)))
      return (item->null_value= true);
     check_partition_func_processor(void *int_arg) override {return TRUE;}
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_dayname>(thd, this); }
};


class Item_func_seconds_hybrid: public Item_func_numhybrid
{
public:
  Item_func_seconds_hybrid(THD *thd): Item_func_numhybrid(thd) {}
  Item_func_seconds_hybrid(THD *thd, Item *a): Item_func_numhybrid(thd, a) {}
  void fix_length_and_dec_generic(uint dec)
  {
    DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
    decimals= dec;
    max_length=17 + (decimals ? decimals + 1 : 0);
    set_maybe_null();
    if (decimals)
      set_handler(&type_handler_newdecimal);
    else
      set_handler(type_handler_long_or_longlong());
  }
  double real_op() override { DBUG_ASSERT(0); return 0; }
  String *str_o Returns true
   * if the internal linked list has no entries, false otherwise.
   */
  bool is_empty() { return m_trx_front == NULL; }

};

/**
   The extension class for the master of semi-synchronous replication
*/
class Repl_semi_sync_master
  :public Repl_semi_sync_base {
  Active_tranx    *m_active_tranxs;  /* active transaction list: the list will
                                      be cleared when semi-sync switches off. */

  /* True when init_object has been called */
  bool m_init_done;

  /* This cond variable is signaled when enough binlog has been sent to slave,
   * so that a waiting trx can return the 'ok' to the client for a commit.
   */
  mysql_cond_t  COND_binlog_send;

  /* Mutex that protects the following state variables and the active
   * transaction list.
   * Under no cirumstances we can acquire mysql_bin_log.LOCK_log if we are
   * already holding m_LOCK_binlog because it can cause deadlocks.
   */
  mysql_mutex_t LOCK_binlog;

  /* This is set to true when m_reply_file_name conton, MA  02110-1335  USA */


#ifndef SEMISYNC_MASTER_H
#define SEMISYNC_MASTER_H

#include "semisync.h"
#include "semisync_master_ack_receiver.h"

#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key key_LOCK_rpl_semi_sync_master_enabled;
extern PSI_mutex_key key_LOCK_binlog;
extern PSI_cond_key key_COND_binlog_send;
#endif

struct Tranx_node {
  char              log_name[FN_REFLEN];
  bool              thd_valid;             /* thd is valid for signalling */
  my_off_t          log_pos;
  THD               *thd;                   /* The thread awaiting an ACK */
  struct Tranx_node *next;            /* the next node in the sorted list */
  struct Tranx_node *hash_next;    /* the next node during hash collision */
};

/**
  @class Tranx_node_allocator

  This class provides memory allocating and freeing methods for
  Tranx_node. The main target is performance.

  @section ALLOCATE How to allocate a node
    The pointer of the first node after 'last_node' in current_block is
    returned. current_block will move to field,
      so ::make_new_field is not applicable. But we still need to
      preserve the original field metadata for the client-server
      protocol.
    */
    orig_table= orig_table_arg;
  }

  /* maximum possible display length */
  virtual uint32 max_display_length() const= 0;
  /**
    Whether a field being created has the samle type.
    Used by the ALTER TABLE
  */
  virtual bool is_equal(const Column_definition &new_field) const= 0;
  /* convert decimal to longlong with overflow check */
  longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag,
                                    int *err);
  /*
    Maximum number of bytes in character representation.
    - For string types it is equal to the field capacity, in bytes.
    - For non-string types it represents the longest possible string length
      after conversion to string.
  */
  virtual uint32 character_octet_length() const
  {
    return field_length;
  }
  /* The max. number of characters */
  virtual uint32 char_length pointer to the item by which this field
    can be computed from other fields.
  */
  Virtual_column_info *vcol_info, *check_constraint, *default_value;

  Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
        uchar null_bit_arg, utype unireg_check_arg,
        const LEX_CSTRING *field_name_arg);
  virtual ~Field() = default;

  virtual Type_numeric_attributes type_numeric_attributes() const
  {
    return Type_numeric_attributes(field_length, decimals(), is_unsigned());
  }
  Type_std_attributes type_std_attributes() const
  {
    return Type_std_attributes(type_numeric_attributes(), dtcollation());
  }

  bool is_unsigned() const { return flags & UNSIGNED_FLAG; }

  bool check_assignability_from(const Type_handler *from, bool ignore) const;
  bool check_assignability_from(const Field *from, bool ignore) const
  {
    return check_assignability_from(from->type_handler(), ignore);
  }

  /**
    Convenience definition of a copy function returned by
    Field::get_copy_func()
  */
  typedef void       (e.g. "INTEGER", "DECIMAL", "DOUBLE")
      @param cs          - character set of the original string
      @param str         - the original string
      @param end         - the end of the string
      @param allow_notes - tells if trailing space notes should be displayed
                           or suppressed.

      Unlike Field_num::check_edom_and_truncation(), this function does not
      distinguish between EDOM and truncation and reports the same warning for
      both cases. Perhaps we should eventually print different warnings,
      to make the explicit CAST work closer to the implicit cast in
      Field_xxx::store().
    */
    void check_edom_and_truncation(THD *thd, Warn_filter filter,
                                   const char *type,
                                   CHARSET_INFO *cs,
                                   const char *str,
                                   size_t length) const;
  public:
    int error() const { return m_error; }
  };

  class Converter_strntod: publicount_++;
    return false;
  }

  enum Sumfunctype sum_func() const override
  {
    return CUME_DIST_FUNC;
  }

  void clear() override
  {
    current_row_count_= 0;
    partition_row_count_= 0;
  }

  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("cume_dist") };
    return name;
  }

  void update_field() override {}
  const Type_handler *type_handler() const override
  { return &type_handler_double; }

  bool fix_length_and_dec(THD *thd) override
  {
    decimals = 10;  // TODO-cvicentiu find out how many decimals the standard
                    // requires.
    return FALSE;
  }
  
  void reset_field() override { DBUG_ASSERT(0); }

  void set_partition_row_count(ulonglong count) override
  {
    Partition_row_count::set_partition_row_count(count);
  }

  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_sum_cume_dist>(thd, this); }

};

class Item_sum_ntile : public Item_sum_int,
                       public Partition_row_count,, 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 16, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,  0
};

static unsigned char uctype_page4D[256]=
{
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,
  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2
};

static unsigned char uctype_page05[256]=
{
  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,
  1,  2,  1,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  0,  0,  2, 16, 16, 16, 16, 16, 16,
  0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  0, 16, 16,  0,  0,  0,  0,  0,
  0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 16, 18,
 16, 18, 18, 16, 18, 18, 16, 18,  0,  0,  0,  0,  0,  0,  0,  0,
  2, sages for the mysqld daemon are in sql/share/errmsg.txt
*/

#ifdef	__cplusplus
extern "C" {
#endif
void	init_client_errs(void);
void	finish_client_errs(void);
extern const char *client_errors[];	/* Error messages */
#ifdef	__cplusplus
}
#endif

#define CR_MIN_ERROR		2000	/* For easier client code */
#define CR_MAX_ERROR		2999
#if !defined(ER)
#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST) \
               ? client_errors[(X)-CR_ERROR_FIRST]             \
               : client_errors[CR_UNKNOWN_ERROR-CR_ERROR_FIRST])

#endif
#define CLIENT_ERRMAP		2	/* Errormap used by my_error() */

/* Do not add error numbers before CR_ERROR_FIRST. */
/* If necessary to add lower numbers, change CR_ERROR_FIRST accordingly. */
#define CR_ERROR_FIRST  	2000 /*Copy first error nr.*/
#define CR_UNKNOWN_ERROR	2000
#define CR_SOCKET_CREATE_ERROR	2001
#define CR_CONNECTION_ERROR	2002
#define CR_CONN_HOST_ERROR	2003
#define CR_IPSOCK_ERROR		2004
#define CR_UNKNOWN_HOST		2005
#define CR_SERVER_GONE_ERROR	2006
#defintions
  */
  uint allowed_join_cache_types;
  bool allowed_semijoin_with_cache;
  bool allowed_outer_join_with_cache;
  /* Maximum level of the join caches that can be used for join operations */ 
  uint max_allowed_join_cache_level;
  select_result *result;
  TMP_TABLE_PARAM tmp_table_param;
  MYSQL_LOCK *lock;
  /// unit structure (with global parameters) for this select
  SELECT_LEX_UNIT *unit;
  /// select that processed
  SELECT_LEX *select_lex;
  /** 
    TRUE <=> optimizer must not mark any table as a constant table.
    This is needed for subqueries in form "a IN (SELECT .. UNION SELECT ..):
    when we optimize the select that reads the results of the union from a
    temporary table, we must not mark the temp. table as constant because
    the number of rows in it may vary from one subquery execution to another.
  */
  bool no_const_tables; 
  /*
    This flag is set if we call no_rows_in_result() as par of end_group().
    This is used as a simple speed optimization to avoiding calling
    restore_used= FALSE;
  }

  void set_from_prev(POSITION *prev) override;
  bool check_qep(JOIN *join,
                 uint idx,
                 table_map remaining_tables, 
                 const JOIN_TAB *new_join_tab,
                 double *record_count,
                 double *read_time,
                 table_map *handled_fanout,
                 sj_strategy_enum *strategy,
                 POSITION *loose_scan_pos) override;

  void mark_used() override { is_used= TRUE; }
  friend void fix_semijoin_strategies_for_picked_join_order(JOIN *join);
};


class LooseScan_picker : public Semi_join_strategy_picker
{
public:
  /* The first (i.e. driving) table we're doing loose scan for */
  uint        first_loosescan_table;
  /* 
     Tables that need to be in the prefix before we can calculate the cost
     of using LooseScan strategy.
  */
  table_map   loosescan_need_tables;

  /*
    keyno  -  Planning to do LooseScan on this key. If keyuse is NULL then 
              this is a full index scan, otherwise this iandle
  @return      error text
*/
const char *thd_get_error_message(const MYSQL_THD thd);
/**
  Return error number
  @param thd   user thread connection handle
  @return      error number
*/
unsigned int thd_get_error_number(const MYSQL_THD thd);
/**
  Return the current row number (i.e. in a multiple INSERT statement)
  @param thd   user thread connection handle
  @return      row number
*/
unsigned long thd_get_error_row(const MYSQL_THD thd);
/**
  Increment the current row number
  @param thd   user thread connection handle
*/
void thd_inc_error_row(MYSQL_THD thd);
/**
  Return a text description of a thread, its security context (user,host)
  and the current query.
*/
char *thd_get_error_context_description(MYSQL_THD thd,
                                        char *buffer, unsigned int length,
                                        unsigned int max_query_length);
#endif

#ifdef __cplusplus
}
#endif

#define MYSQL_SERVICE_THD_STMT_DA_INCLUDED
#endif
/*
   Copyright (c) 2021, MariaDB Corporation.

   Tments of
    enum_binlog_stmt_unsafe.
  */
  inline void clear_stmt_unsafe() {
    DBUG_ENTER("clear_stmt_unsafe");
    binlog_stmt_flags&= ~BINLOG_STMT_UNSAFE_ALL_FLAGS;
    DBUG_VOID_RETURN;
  }

  /**
    Determine if this statement is a row injection.

    @retval 0 if the statement is not a row injection
    @retval nonzero if the statement is a row injection
  */
  inline bool is_stmt_row_injection() const {
    return binlog_stmt_flags & (1U << BINLOG_STMT_TYPE_ROW_INJECTION);
  }

  /**
    Flag the statement as a row injection.  A row injection is either
    a BINLOG statement, or a row event in the relay log executed by
    the slave SQL thread.
  */
  inline void set_stmt_row_injection() {
    DBUG_ENTER("set_stmt_row_injection");
    binlog_stmt_flags|= (1U << BINLOG_STMT_TYPE_ROW_INJECTION);
    DBUG_VOID_RETURN;
  }

  enum enum_stmt_accessed_table
  {
    /*
       If a transactional table is about to be read. Note that
       a write implies a read.
    */
    STMT_READS_TRANS_TABLE= 0,
    /*ke_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
                              bool open_view_no_parse);
  friend class st_select_lex;
private:
  void fast_exclude();
};
typedef class st_select_lex_node SELECT_LEX_NODE;

/* 
   SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group 
   SELECT_LEXs
*/
class THD;
class select_result;
class JOIN;
class select_unit;
class Procedure;
class Explain_query;

void delete_explain_query(LEX *lex);
void create_explain_query(LEX *lex, MEM_ROOT *mem_root);
void create_explain_query_if_not_exists(LEX *lex, MEM_ROOT *mem_root);
bool print_explain_for_slow_log(LEX *lex, THD *thd, String *str);


class st_select_lex_unit: public st_select_lex_node {
protected:
  TABLE_LIST result_table_list;
  select_unit *union_result;
  ulonglong found_rows_for_union;

  bool prepare_join(THD *thd, SELECT_LEX *sl, select_result *result,
                    ulonglong additional_options,
                    bool is_union_select);
  bool join_union_type_handlers(THD *thd,
     _call((const char*)"get_date");
    return true;
  }
  bool fix_fields(THD *thd, Item **ref) override;
  void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge)
    override;
  void cleanup() override;
  void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
                      List<Item> &fields, uint flags) override;
  table_map used_tables() const override { return used_tables_cache; };
  bool const_item() const override { return const_item_cache; };
  void update_used_tables() override
  {
    used_tables_and_const_cache_init();
    used_tables_and_const_cache_update_and_join(arg_count, args);
  }
  table_map not_null_tables() const override { return not_null_tables_cache; }
  void print(String *str, enum_query_type query_type) override;

  bool walk(Item_processor processor, bool walk_subquery, void *arg) override
  {
    if (walk_args(processor, walk_subquery, arg))
      return true;
    return (this->*processor)(arg);
  }
  Item *transform(THD *thd, Item_transformer transfothe requested
      privileges was denied.
      @retval ACL_INTERNAL_ACCESS_CHECK_GRANT No requested privilege
      was denied, and grant should be checked for at least one
      privilege. Requested privileges that are granted, if any, are saved
      in save_priv.
  */
  virtual ACL_internal_access_result check(privilege_t want_access,
                                           privilege_t *save_priv) const= 0;

  /**
    Search for per table ACL access rules by table name.
    @param name the table name
    @return per table access rules, or NULL
  */
  virtual const ACL_internal_table_access *lookup(const char *name) const= 0;
};

/**
  A registry for per internal schema ACL.
  An 'internal schema' is a database schema maintained by the
  server implementation, such as 'performance_schema' and 'INFORMATION_SCHEMA'.
*/
class ACL_internal_schema_registry
{
public:
  static void register_schema(const LEX_CSTRING *name,
                              const ACL_internal_schema_access *access);
  static const  of this type are
    allocated on MEM_ROOT and should not require destruction.
  */
  virtual ~Time_zone() = default;

  /**
    Check if the time zone does not have any anomalies around "sec", such as:
    - DST changes (spring forward, fall back)
    - leap seconds (the 60-th second)
  */
  bool is_monotone_continuous_around(my_time_t sec) const;

protected:
  static inline void adjust_leap_second(MYSQL_TIME *t);
};

extern Time_zone * my_tz_UTC;
extern MYSQL_PLUGIN_IMPORT Time_zone * my_tz_SYSTEM;
extern Time_zone * my_tz_OFFSET0;
extern Time_zone * my_tz_find(THD *thd, const String *name);
extern my_bool     my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap);
extern void        my_tz_free();
extern my_time_t   sec_since_epoch_TIME(MYSQL_TIME *t);

/**
  Number of elements in table list produced by my_tz_get_table_list()
  (this table list contains tables which are needed for dynamical loading
  of time zone descriptions). Actually it is imlementation detail that
  should not be used  tables this member is NULL.
  */
  ulong *rec_per_key;

  /*
    This structure is used for statistical data on the index
    that has been read from the statistical table index_stat
  */ 
  Index_statistics *read_stats;
  /*
    This structure is used for statistical data on the index that
    is collected by the function collect_statistics_for_table
  */
  Index_statistics *collected_stats;
 
  TABLE *table;
  LEX_CSTRING comment;
  /** reference to the list of options or NULL */
  engine_option_value *option_list;
  ha_index_option_struct *option_struct;                  /* structure with parsed options */

  double actual_rec_per_key(uint i) const;
} KEY;


struct st_join_table;

typedef struct st_reginfo {		/* Extra info about reg */
  struct st_join_table *join_tab;	/* Used by SELECT() */
  enum thr_lock_type lock_type;		/* How database is used */
  bool skip_locked;
  bool not_exists_optimize;
  /*
    TRUE <=> range optimizer found that there is no rows satisfying
    table conditions.
  */
  bool im);
}


static inline constexpr
Lex_ident_plugin operator""_Lex_ident_plugin(const char *str, size_t length)
{
  return Lex_ident_plugin(str, length);
}


template<size_t buff_sz>
class IdentBuffer: public CharBuffer<buff_sz>
{
  constexpr static CHARSET_INFO *charset()
  {
    return &my_charset_utf8mb3_general_ci;
  }
public:
  IdentBuffer()
  { }
  IdentBuffer<buff_sz> & copy_casedn(const LEX_CSTRING &str)
  {
    CharBuffer<buff_sz>::copy_casedn(charset(), str);
    return *this;
  }
};


template<size_t buff_sz>
class IdentBufferCasedn: public IdentBuffer<buff_sz>
{
public:
  IdentBufferCasedn(const LEX_CSTRING &str)
  {
    IdentBuffer<buff_sz>::copy_casedn(str);
  }
};


/*
  A helper class to store temporary database names in a buffer.
  After constructing it's typically should be checked using
  Lex_ident_db::check_name().

  Note, the database name passed to the constructor can originally
  come from the parser and can be of an atribtrary long length.
  Let's reserve additional buffer space for one ereturn singleton(); }
    bool fix_length_and_dec(THD *thd) override
    {
      Type_std_attributes::operator=(Type_std_attributes_fbt());
      return false;
    }
    String *val_str(String *to) override
    {
      Fbt_null tmp(args[0]);
      return (null_value= tmp.is_null() || tmp.to_string(to)) ? NULL : to;
    }
    longlong val_int() override
    {
      return 0;
    }
    double val_real() override
    {
      return 0;
    }
    my_decimal *val_decimal(my_decimal *to) override
    {
      my_decimal_set_zero(to);
      return to;
    }
    bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
    {
      set_zero_time(ltime, MYSQL_TIMESTAMP_TIME);
      return false;
    }
  };

  class Item_typecast_fbt: public Item_fbt_func
  {
  public:
    Item_typecast_fbt(THD *thd, Item *a) :Item_fbt_func(thd, a) {}

    Item_func::Functype functype() const override
    { return Item_func::CHAR_TYPECAST_FUNC; }
    bool eq(const Item *item, bool binary_cmp) const override
    {
      if) ||
        mysql_file_sync(cache_log.file, MYF(0)))
      return true;
    return false;
  }

  /**
    Copy the name of the cache file to the argument name.
  */
  const char *temp_file_name() { return my_filename(cache_log.file); }

  /**
    It is called after renaming the cache file to a binlog file. The file
    now is a binlog file, so detach it from the binlog cache.
  */
  void detach_temp_file();

  /*
    Cache to store data before copying it to the binary log.
  */
  IO_CACHE cache_log;

protected:
  /*
    Binlog position before the start of the current statement.
  */
  my_off_t before_stmt_pos;

private:
  /*
    Pending binrows event. This event is the event where the rows are currently
    written.
   */
  Rows_log_event *m_pending;

  /*
    Bit flags for what has been writing to cache. Used to
    discard logs without any data changes.
    see enum_logged_status;
  */
  uint32 status;

public:
  /*
    The algorithm (if any) used to pre-compute checksums in the cache.
    Initialized from ve() override
  {
    if (as_window_function)
    {
      remove_as_window(args[0]->val_int());
      return;
    }
    // Unless we're counting bits, we can not remove anything.
    DBUG_ASSERT(0);
  }

  bool supports_removal() const override
  {
    return true;
  }

protected:
  enum bit_counters { NUM_BIT_COUNTERS= 64 };
  ulonglong reset_bits,bits;
  /*
    Marks whether the function is to be computed as a window function.
  */
  bool as_window_function;
  // When used as an aggregate window function, we need to store
  // this additional information.
  ulonglong num_values_added;
  ulonglong bit_counters[NUM_BIT_COUNTERS];
  bool add_as_window(ulonglong value);
  bool remove_as_window(ulonglong value);
  bool clear_as_window();
  virtual void set_bits_from_counters()= 0;
};


class Item_sum_or final :public Item_sum_bit
{
public:
  Item_sum_or(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {}
  Item_sum_or(THD *thd, Item_sum_or *item) :Item_sum_bit(thd, item) {}
  bool add() override;
  LEX_ide;
  longlong val_int() override;
  String *val_str(String*str) override;
  my_decimal *val_decimal(my_decimal *) override;
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
  {
    return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);
  }
  const Type_handler *type_handler() const override
  { return Type_handler_hybrid_field_type::type_handler(); }
  void fix_length_and_dec_double();
  void fix_length_and_dec_decimal();
  void reset_field() override;
  void update_field() override;
  void no_rows_in_result() override {}
  LEX_CSTRING func_name_cstring() const override
  { 
    static LEX_CSTRING name_distinct= { STRING_WITH_LEN("sum(distinct ")};
    static LEX_CSTRING name_normal=   { STRING_WITH_LEN("sum(") };
    return has_with_distinct() ? name_distinct : name_normal;
  }
  Item *copy_or_same(THD* thd) override;
  void remove() override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_sum_sum>(thd, this); }

  bool supports_
protected:
  CHARSET_INFO *m_ci;
  Type m_type;
public:
  void init(CHARSET_INFO *ci, Type type)
  {
    m_ci= ci;
    m_type= type;
  }
  CHARSET_INFO *charset_info() const { return m_ci; }
  Type type() const { return m_type; }
  LEX_CSTRING collation_name_for_show() const
  {
    switch (m_type) {
    case TYPE_CONTEXTUALLY_TYPED:
      return Lex_context_collation(m_ci).collation_name_for_show();
    case TYPE_EXACT:
      return m_ci->coll_name;
    }
    DBUG_ASSERT(0);
    return m_ci->coll_name;
  }
  static Lex_extended_collation_st collate_default()
  {
    Lex_extended_collation_st res;
    res.set_collate_default();
    return res;
  }
  void set_collate_default()
  {
    m_ci= &my_collation_contextually_typed_default;
    m_type= TYPE_CONTEXTUALLY_TYPED;
  }
  bool set_by_name(const char *name, myf my_flags); // e.g. MY_UTF8_IS_UTF8MB3
  bool raise_if_conflicts_with_context_collation(const Lex_context_collation &)
                                                 const;
  bool merge_exact_charsete(const MYSQL *mysql);
unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql);

/********************************************************************
  mysql_net_ functions - low-level API to MySQL protocol
*********************************************************************/
unsigned long STDCALL mysql_net_read_packet(MYSQL *mysql);
unsigned long STDCALL mysql_net_field_length(unsigned char **packet);

/* status return codes */
#define MYSQL_NO_DATA        100
#define MYSQL_DATA_TRUNCATED 101

#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)

#ifdef USE_OLD_FUNCTIONS
MYSQL *		STDCALL mysql_connect(MYSQL *mysql, const char *host,
				      const char *user, const char *passwd);
int		STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
int		STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
#endif
#define HAVE_MYSQL_REAL_CONNECT

#ifdef	__cplusplus
}
#endif

#endif /* _mysql_h */
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
   Copyright (c) 2011, 2013, Monty ProgOracle and/or its affiliates.
   Copyright (c) 2008, 2013, SkySQL Ab.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335  USA */

#ifndef RPL_RECORD_H
#define RPL_RECORD_H

#include <rpl_reporting.h>

struct rpl_group_info;
struct TABLE;
typedef struct st_bitm