Commit 58e759a9 authored by Michael Widenius's avatar Michael Widenius Committed by Oleksandr Byelkin

Added 'final' to some classes to improve generated code

Final added to:
- All reasonable classes inhereted from Field
- All classes inhereted from Protocol
- Almost all Handler classes
- Some important Item classes

The stripped size of mariadbd is just 4K smaller, but several object files
showed notable improvements in common execution paths.
- Checked field.o and item_sum.o

Other things:
- Added 'override' to a few class functions touched by this patch.
- Removed 'virtual' from a new class functions that had/got 'override'
- Changed Protocol_discard to inherit from Protocol instad of Protocol_text
parent 48b5777e
This diff is collapsed.
......@@ -2157,7 +2157,7 @@ class Item_aggregate_ref : public Item_ref
const LEX_CSTRING &field_name_arg):
Item_ref(thd, context_arg, item, table_name_arg, field_name_arg) {}
virtual inline void print (String *str, enum_query_type query_type)
void print (String *str, enum_query_type query_type) override
{
if (ref)
(*ref)->print(str, query_type);
......
......@@ -744,7 +744,7 @@ class Item_func_eq :public Item_bool_rowready_func2
{ return get_item_copy<Item_func_eq>(thd, this); }
};
class Item_func_equal :public Item_bool_rowready_func2
class Item_func_equal final :public Item_bool_rowready_func2
{
public:
Item_func_equal(THD *thd, Item *a, Item *b):
......@@ -3331,7 +3331,7 @@ class Item_equal_fields_iterator_slow
};
class Item_cond_and :public Item_cond
class Item_cond_and final :public Item_cond
{
public:
COND_EQUAL m_cond_equal; /* contains list of Item_equal objects for
......@@ -3368,7 +3368,7 @@ inline bool is_cond_and(Item *item)
return func_item && func_item->functype() == Item_func::COND_AND_FUNC;
}
class Item_cond_or :public Item_cond
class Item_cond_or final :public Item_cond
{
public:
Item_cond_or(THD *thd): Item_cond(thd) {}
......
......@@ -1016,7 +1016,7 @@ class Stddev
class Item_sum_variance : public Item_sum_double
class Item_sum_variance :public Item_sum_double
{
Stddev m_stddev;
bool fix_length_and_dec();
......@@ -1033,13 +1033,13 @@ class Item_sum_variance : public Item_sum_double
enum Sumfunctype sum_func () const { return VARIANCE_FUNC; }
void fix_length_and_dec_double();
void fix_length_and_dec_decimal();
void clear();
bool add();
void clear() override final;
bool add() override final;
double val_real();
void reset_field();
void update_field();
void reset_field() override final;
void update_field() override final;
Item *result_item(THD *thd, Field *field);
void no_rows_in_result() {}
void no_rows_in_result() override final {}
const char *func_name() const
{ return sample ? "var_samp(" : "variance("; }
Item *copy_or_same(THD* thd);
......@@ -1057,7 +1057,7 @@ class Item_sum_variance : public Item_sum_double
standard_deviation(a) = sqrt(variance(a))
*/
class Item_sum_std :public Item_sum_variance
class Item_sum_std final :public Item_sum_variance
{
public:
Item_sum_std(THD *thd, Item *item_par, uint sample_arg):
......@@ -1075,7 +1075,7 @@ class Item_sum_std :public Item_sum_variance
};
class Item_sum_hybrid: public Item_sum,
class Item_sum_hybrid : public Item_sum,
public Type_handler_hybrid_field_type
{
public:
......@@ -1156,7 +1156,7 @@ class Item_sum_min_max :public Item_sum_hybrid
};
class Item_sum_min :public Item_sum_min_max
class Item_sum_min final :public Item_sum_min_max
{
public:
Item_sum_min(THD *thd, Item *item_par): Item_sum_min_max(thd, item_par, 1) {}
......@@ -1171,7 +1171,7 @@ class Item_sum_min :public Item_sum_min_max
};
class Item_sum_max :public Item_sum_min_max
class Item_sum_max final :public Item_sum_min_max
{
public:
Item_sum_max(THD *thd, Item *item_par): Item_sum_min_max(thd, item_par, -1) {}
......@@ -1260,7 +1260,7 @@ class Item_sum_bit :public Item_sum_int
};
class Item_sum_or :public Item_sum_bit
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) {}
......@@ -1276,7 +1276,7 @@ class Item_sum_or :public Item_sum_bit
};
class Item_sum_and :public Item_sum_bit
class Item_sum_and final :public Item_sum_bit
{
public:
Item_sum_and(THD *thd, Item *item_par):
......@@ -1292,7 +1292,7 @@ class Item_sum_and :public Item_sum_bit
void set_bits_from_counters();
};
class Item_sum_xor :public Item_sum_bit
class Item_sum_xor final :public Item_sum_bit
{
public:
Item_sum_xor(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {}
......@@ -1359,7 +1359,7 @@ struct st_sp_security_context;
Example:
DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN ret_val;
*/
class Item_sum_sp :public Item_sum,
class Item_sum_sp final :public Item_sum,
public Item_sp
{
private:
......
......@@ -190,7 +190,8 @@ class Protocol
Before adding a new type, please make sure
there is enough storage for it in Query_cache_query_flags.
*/
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1, PROTOCOL_LOCAL= 2
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1, PROTOCOL_LOCAL= 2,
PROTOCOL_DISCARD= 3 /* Should be last, not used by Query_cache */
};
virtual enum enum_protocol_type type()= 0;
......@@ -204,7 +205,7 @@ class Protocol
/** Class used for the old (MySQL 4.0 protocol). */
class Protocol_text :public Protocol
class Protocol_text final :public Protocol
{
public:
Protocol_text(THD *thd_arg, ulong prealloc= 0)
......@@ -242,11 +243,11 @@ class Protocol_text :public Protocol
bool store_field_metadata_for_list_fields(const THD *thd, Field *field,
const TABLE_LIST *table_list,
uint pos);
virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
enum enum_protocol_type type() override { return PROTOCOL_TEXT; };
};
class Protocol_binary :public Protocol
class Protocol_binary final :public Protocol
{
private:
uint bit_fields;
......@@ -279,7 +280,7 @@ class Protocol_binary :public Protocol
virtual bool send_out_parameters(List<Item_param> *sp_params);
virtual enum enum_protocol_type type() { return PROTOCOL_BINARY; };
enum enum_protocol_type type() override { return PROTOCOL_BINARY; };
};
......@@ -297,37 +298,38 @@ class Protocol_binary :public Protocol
select_send::send_data() & co., and also uses Protocol_discard object.
*/
class Protocol_discard : public Protocol_text
class Protocol_discard final : public Protocol
{
public:
Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {}
bool write() { return 0; }
bool send_result_set_metadata(List<Item> *, uint) { return 0; }
bool send_eof(uint, uint) { return 0; }
void prepare_for_resend() { IF_DBUG(field_pos= 0,); }
Protocol_discard(THD *thd_arg) : Protocol(thd_arg) {}
bool write() override { return 0; }
bool send_result_set_metadata(List<Item> *, uint) override { return 0; }
bool send_eof(uint, uint) override { return 0; }
void prepare_for_resend() override { IF_DBUG(field_pos= 0,); }
bool send_out_parameters(List<Item_param> *sp_params) override { return false; }
/*
Provide dummy overrides for any storage methods so that we
avoid allocating and copying of data
*/
bool store_null() { return false; }
bool store_tiny(longlong) { return false; }
bool store_short(longlong) { return false; }
bool store_long(longlong) { return false; }
bool store_longlong(longlong, bool) { return false; }
bool store_decimal(const my_decimal *) { return false; }
bool store_null() override { return false; }
bool store_tiny(longlong) override { return false; }
bool store_short(longlong) override { return false; }
bool store_long(longlong) override { return false; }
bool store_longlong(longlong, bool) override { return false; }
bool store_decimal(const my_decimal *) override { return false; }
bool store_str(const char *, size_t, CHARSET_INFO *, my_repertoire_t,
CHARSET_INFO *)
CHARSET_INFO *) override
{
return false;
}
bool store(MYSQL_TIME *, int) { return false; }
bool store_date(MYSQL_TIME *) { return false; }
bool store_time(MYSQL_TIME *, int) { return false; }
bool store(float, uint32, String *) { return false; }
bool store(double, uint32, String *) { return false; }
bool store(Field *) { return false; }
bool store(MYSQL_TIME *, int) override { return false; }
bool store_date(MYSQL_TIME *) override { return false; }
bool store_time(MYSQL_TIME *, int) override { return false; }
bool store(float, uint32, String *) override { return false; }
bool store(double, uint32, String *) override { return false; }
bool store(Field *) override { return false; }
enum enum_protocol_type type() override { return PROTOCOL_DISCARD; };
};
......
......@@ -73,7 +73,7 @@ class Archive_share : public Handler_share
*/
#define ARCHIVE_VERSION 3
class ha_archive: public handler
class ha_archive final : public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
Archive_share *share; /* Shared lock info */
......
......@@ -36,7 +36,7 @@ struct st_blackhole_share {
Class definition for the blackhole storage engine
"Dumbest named feature ever"
*/
class ha_blackhole: public handler
class ha_blackhole final : public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
st_blackhole_share *share;
......
......@@ -144,7 +144,7 @@ typedef class ha_connect *PHC;
/** @brief
Class definition for the storage engine
*/
class ha_connect: public handler
class ha_connect final : public handler
{
THR_LOCK_DATA lock; ///< MySQL lock
CONNECT_SHARE *share; ///< Shared lock info
......
......@@ -57,7 +57,7 @@ struct tina_set {
my_off_t end;
};
class ha_tina: public handler
class ha_tina final : public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
TINA_SHARE *share; /* Shared lock info */
......
......@@ -260,7 +260,7 @@ class federatedx_txn
/*
Class definition for the storage engine
*/
class ha_federatedx: public handler
class ha_federatedx final : public handler
{
friend int federatedx_db_init(void *p);
......
......@@ -25,7 +25,7 @@
#include <heap.h>
#include "sql_class.h" /* THD */
class ha_heap: public handler
class ha_heap final : public handler
{
HP_INFO *file;
HP_SHARE *internal_share;
......
......@@ -58,7 +58,7 @@ struct st_handler_tablename
const char *tablename;
};
/** The class defining a handle to an Innodb table */
class ha_innobase final: public handler
class ha_innobase final : public handler
{
public:
ha_innobase(handlerton* hton, TABLE_SHARE* table_arg);
......
......@@ -39,6 +39,11 @@ C_MODE_END
extern TYPELIB maria_recover_typelib;
extern ulonglong maria_recover_options;
/*
In the ha_maria class there are a few virtual methods that are not marked as
'final'. This is because they are re-defined by the ha_s3 engine.
*/
class __attribute__((visibility("default"))) ha_maria :public handler
{
public:
......@@ -61,98 +66,98 @@ class __attribute__((visibility("default"))) ha_maria :public handler
ha_maria(handlerton *hton, TABLE_SHARE * table_arg);
~ha_maria() {}
handler *clone(const char *name, MEM_ROOT *mem_root);
const char *index_type(uint key_number);
ulonglong table_flags() const
const char *index_type(uint key_number) override final;
ulonglong table_flags() const override final
{ return int_table_flags; }
ulong index_flags(uint inx, uint part, bool all_parts) const;
uint max_supported_keys() const
ulong index_flags(uint inx, uint part, bool all_parts) const override final;
uint max_supported_keys() const override final
{ return MARIA_MAX_KEY; }
uint max_supported_key_length() const;
uint max_supported_key_part_length() const
uint max_supported_key_length() const override final;
uint max_supported_key_part_length() const override final
{ return max_supported_key_length(); }
enum row_type get_row_type() const;
void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
virtual double scan_time();
int open(const char *name, int mode, uint test_if_locked);
int close(void);
int write_row(const uchar * buf);
int update_row(const uchar * old_data, const uchar * new_data);
int delete_row(const uchar * buf);
enum row_type get_row_type() const override final;
void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) override final;
virtual double scan_time() override final;
int open(const char *name, int mode, uint test_if_locked) override;
int close(void) override final;
int write_row(const uchar * buf) override;
int update_row(const uchar * old_data, const uchar * new_data) override;
int delete_row(const uchar * buf) override;
int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map,
enum ha_rkey_function find_flag);
enum ha_rkey_function find_flag) override final;
int index_read_idx_map(uchar * buf, uint idx, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag);
enum ha_rkey_function find_flag) override final;
int index_read_last_map(uchar * buf, const uchar * key,
key_part_map keypart_map);
int index_next(uchar * buf);
int index_prev(uchar * buf);
int index_first(uchar * buf);
int index_last(uchar * buf);
int index_next_same(uchar * buf, const uchar * key, uint keylen);
int ft_init()
key_part_map keypart_map) override final;
int index_next(uchar * buf) override final;
int index_prev(uchar * buf) override final;
int index_first(uchar * buf) override final;
int index_last(uchar * buf) override final;
int index_next_same(uchar * buf, const uchar * key, uint keylen) override final;
int ft_init() override final
{
if (!ft_handler)
return 1;
ft_handler->please->reinit_search(ft_handler);
return 0;
}
FT_INFO *ft_init_ext(uint flags, uint inx, String * key);
int ft_read(uchar * buf);
int index_init(uint idx, bool sorted);
int index_end();
int rnd_init(bool scan);
int rnd_end(void);
int rnd_next(uchar * buf);
int rnd_pos(uchar * buf, uchar * pos);
int remember_rnd_pos();
int restart_rnd_next(uchar * buf);
void position(const uchar * record);
int info(uint);
FT_INFO *ft_init_ext(uint flags, uint inx, String * key) override final;
int ft_read(uchar * buf) override final;
int index_init(uint idx, bool sorted) override final;
int index_end() override final;
int rnd_init(bool scan) override final;
int rnd_end(void) override final;
int rnd_next(uchar * buf) override final;
int rnd_pos(uchar * buf, uchar * pos) override final;
int remember_rnd_pos() override final;
int restart_rnd_next(uchar * buf) override final;
void position(const uchar * record) override final;
int info(uint) override final;
int info(uint, my_bool);
int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size);
int reset(void);
int external_lock(THD * thd, int lock_type);
int start_stmt(THD *thd, thr_lock_type lock_type);
int delete_all_rows(void);
int disable_indexes(uint mode);
int enable_indexes(uint mode);
int indexes_are_disabled(void);
void start_bulk_insert(ha_rows rows, uint flags);
int end_bulk_insert();
int extra(enum ha_extra_function operation) override final;
int extra_opt(enum ha_extra_function operation, ulong cache_size) override final;
int reset(void) override final;
int external_lock(THD * thd, int lock_type) override;
int start_stmt(THD *thd, thr_lock_type lock_type) override final;
int delete_all_rows(void) override final;
int disable_indexes(uint mode) override final;
int enable_indexes(uint mode) override final;
int indexes_are_disabled(void) override final;
void start_bulk_insert(ha_rows rows, uint flags) override final;
int end_bulk_insert() override final;
ha_rows records_in_range(uint inx, const key_range *min_key,
const key_range *max_key,
page_range *pages);
void update_create_info(HA_CREATE_INFO * create_info);
int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info);
page_range *pages) override final;
void update_create_info(HA_CREATE_INFO * create_info) override final;
int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info) override;
THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
enum thr_lock_type lock_type);
enum thr_lock_type lock_type) override final;
virtual void get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values,
ulonglong *first_value,
ulonglong *nb_reserved_values);
int rename_table(const char *from, const char *to);
int delete_table(const char *name);
void drop_table(const char *name);
int check(THD * thd, HA_CHECK_OPT * check_opt);
int analyze(THD * thd, HA_CHECK_OPT * check_opt);
int repair(THD * thd, HA_CHECK_OPT * check_opt);
bool check_and_repair(THD * thd);
bool is_crashed() const;
ulonglong *nb_reserved_values) override final;
int rename_table(const char *from, const char *to) override;
int delete_table(const char *name) override;
void drop_table(const char *name) override;
int check(THD * thd, HA_CHECK_OPT * check_opt) override;
int analyze(THD * thd, HA_CHECK_OPT * check_opt) override;
int repair(THD * thd, HA_CHECK_OPT * check_opt) override;
bool check_and_repair(THD * thd) override final;
bool is_crashed() const override final;
bool is_changed() const;
bool auto_repair(int error) const;
int optimize(THD * thd, HA_CHECK_OPT * check_opt);
int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt);
int preload_keys(THD * thd, HA_CHECK_OPT * check_opt);
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
bool auto_repair(int error) const override final;
int optimize(THD * thd, HA_CHECK_OPT * check_opt) override final;
int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt) override final;
int preload_keys(THD * thd, HA_CHECK_OPT * check_opt) override;
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes) override final;
#ifdef HAVE_QUERY_CACHE
my_bool register_query_cache_table(THD *thd, const char *table_key,
uint key_length,
qc_engine_callback
*engine_callback,
ulonglong *engine_data);
ulonglong *engine_data) override final;
#endif
MARIA_HA *file_ptr(void)
{
......@@ -164,21 +169,21 @@ class __attribute__((visibility("default"))) ha_maria :public handler
* Multi Range Read interface
*/
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(range_id_t *range_info);
uint n_ranges, uint mode, HANDLER_BUFFER *buf) override final;
int multi_range_read_next(range_id_t *range_info) override final;
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, Cost_estimate *cost);
uint *flags, Cost_estimate *cost) override final;
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint *bufsz,
uint *flags, Cost_estimate *cost);
int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size);
uint *flags, Cost_estimate *cost) override final;
int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size) override final;
/* Index condition pushdown implementation */
Item *idx_cond_push(uint keyno, Item* idx_cond);
Item *idx_cond_push(uint keyno, Item* idx_cond) override final;
int find_unique_row(uchar *record, uint unique_idx);
int find_unique_row(uchar *record, uint unique_idx) override final;
/* Following functions are needed by the S3 handler */
virtual S3_INFO *s3_open_args() { return 0; }
......
......@@ -19,7 +19,7 @@
#include "ha_maria.h"
class ha_s3 :public ha_maria
class ha_s3 final :public ha_maria
{
enum alter_table_op
{ S3_NO_ALTER, S3_ALTER_TABLE, S3_ADD_PARTITION, S3_ADD_TMP_PARTITION };
......@@ -31,52 +31,52 @@ class ha_s3 :public ha_maria
~ha_s3() {}
int create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *ha_create_info) final;
int open(const char *name, int mode, uint open_flags) final;
int write_row(const uchar *buf) final;
int update_row(const uchar * old_data, const uchar * new_data) final
HA_CREATE_INFO *ha_create_info);
int open(const char *name, int mode, uint open_flags);
int write_row(const uchar *buf);
int update_row(const uchar * old_data, const uchar * new_data)
{
DBUG_ENTER("update_row");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
int delete_row(const uchar * buf) final
int delete_row(const uchar * buf)
{
DBUG_ENTER("delete_row");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
int check(THD * thd, HA_CHECK_OPT * check_opt) final
int check(THD * thd, HA_CHECK_OPT * check_opt)
{
DBUG_ENTER("delete_row");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
int analyze(THD * thd, HA_CHECK_OPT * check_opt) final
int analyze(THD * thd, HA_CHECK_OPT * check_opt)
{
DBUG_ENTER("analyze");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
int repair(THD * thd, HA_CHECK_OPT * check_opt) final
int repair(THD * thd, HA_CHECK_OPT * check_opt)
{
DBUG_ENTER("repair");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
int preload_keys(THD * thd, HA_CHECK_OPT * check_opt) final
int preload_keys(THD * thd, HA_CHECK_OPT * check_opt)
{
DBUG_ENTER("preload_keys");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
int external_lock(THD * thd, int lock_type) final;
int external_lock(THD * thd, int lock_type);
/*
drop_table() is only used for internal temporary tables,
not applicable for s3
*/
void drop_table(const char *name) final
void drop_table(const char *name)
{
}
int delete_table(const char *name) final;
int rename_table(const char *from, const char *to) final;
int delete_table(const char *name);
int rename_table(const char *from, const char *to);
int discover_check_version() override;
int rebind();
S3_INFO *s3_open_args() final { return open_args; }
void register_handler(MARIA_HA *file) final;
S3_INFO *s3_open_args() { return open_args; }
void register_handler(MARIA_HA *file);
};
#endif /* HA_S3_INCLUDED */
......@@ -41,7 +41,7 @@ C_MODE_START
check_result_t index_cond_func_myisam(void *arg);
C_MODE_END
class ha_myisam: public handler
class ha_myisam final : public handler
{
MI_INFO *file;
ulonglong int_table_flags;
......
......@@ -68,7 +68,7 @@ class Mrg_child_def: public Sql_alloc
};
class ha_myisammrg: public handler
class ha_myisammrg final : public handler
{
MYRG_INFO *file;
my_bool is_cloned; /* This instance has been cloned */
......
......@@ -41,7 +41,7 @@ class PFS_engine_table;
extern const char *pfs_engine_name;
/** A handler for a PERFORMANCE_SCHEMA table. */
class ha_perfschema : public handler
class ha_perfschema final : public handler
{
public:
/**
......
......@@ -53,7 +53,7 @@ class Sequence_share : public Handler_share {
}
};
class ha_seq: public handler
class ha_seq final : public handler
{
private:
THR_LOCK_DATA lock;
......
......@@ -30,7 +30,7 @@ struct CSphSEStats;
struct CSphSEThreadTable;
/// Sphinx SE handler class
class ha_sphinx : public handler
class ha_sphinx final : public handler
{
protected:
THR_LOCK_DATA m_tLock; ///< MySQL lock
......
......@@ -49,7 +49,7 @@ struct st_spider_ft_info
String *key;
};
class ha_spider: public handler
class ha_spider final : public handler
{
public:
SPIDER_SHARE *share;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment