diff options
Diffstat (limited to 'storage/perfschema/pfs_engine_table.h')
-rw-r--r-- | storage/perfschema/pfs_engine_table.h | 199 |
1 files changed, 174 insertions, 25 deletions
diff --git a/storage/perfschema/pfs_engine_table.h b/storage/perfschema/pfs_engine_table.h index ec73c5a3688..40f5404d0b7 100644 --- a/storage/perfschema/pfs_engine_table.h +++ b/storage/perfschema/pfs_engine_table.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -22,8 +22,10 @@ Performance schema tables (declarations). */ +#include "pfs_instr_class.h" class Field; struct PFS_engine_table_share; +struct time_normalizer; /** @addtogroup Performance_schema_engine @@ -46,6 +48,18 @@ public: int update_row(TABLE *table, const unsigned char *old_buf, unsigned char *new_buf, Field **fields); + /** + Delete a row from this table. + @param table Table handle + @param buf the row buffer to delete + @param fields Table fields + @return 0 on success + */ + int delete_row(TABLE *table, const unsigned char *buf, Field **fields); + + /** Initialize table scan. */ + virtual int rnd_init(bool scan){return 0;}; + /** Fetch the next row in this cursor. */ virtual int rnd_next(void)= 0; /** @@ -56,12 +70,82 @@ public: void get_position(void *ref); void set_position(const void *ref); + /** Reset the cursor position to the beginning of the table. */ virtual void reset_position(void)= 0; + /** Get the normalizer and class type for the current row. */ + void get_normalizer(PFS_instr_class *instr_class); + /** Destructor. */ virtual ~PFS_engine_table() {} + /** + Helper, assign a value to a ulong field. + @param f the field to set + @param value the value to assign + */ + static void set_field_ulong(Field *f, ulong value); + /** + Helper, assign a value to a ulonglong field. + @param f the field to set + @param value the value to assign + */ + static void set_field_ulonglong(Field *f, ulonglong value); + /** + Helper, assign a value to a char utf8 field. + @param f the field to set + @param str the string to assign + @param len the length of the string to assign + */ + static void set_field_char_utf8(Field *f, const char *str, uint len); + /** + Helper, assign a value to a varchar utf8 field. + @param f the field to set + @param str the string to assign + @param len the length of the string to assign + */ + static void set_field_varchar_utf8(Field *f, const char *str, uint len); + /** + Helper, assign a value to a longtext utf8 field. + @param f the field to set + @param str the string to assign + @param len the length of the string to assign + */ + static void set_field_longtext_utf8(Field *f, const char *str, uint len); + /** + Helper, assign a value to an enum field. + @param f the field to set + @param value the value to assign + */ + static void set_field_enum(Field *f, ulonglong value); + /** + Helper, assign a value to a timestamp field. + @param f the field to set + @param value the value to assign + */ + static void set_field_timestamp(Field *f, ulonglong value); + /** + Helper, read a value from an enum field. + @param f the field to read + @return the field value + */ + static ulonglong get_field_enum(Field *f); + /** + Helper, read a value from a char utf8 field. + @param f the field to read + @param[out] val the field value + @return the field value + */ + static String *get_field_char_utf8(Field *f, String *val); + /** + Helper, read a value from a varchar utf8 field. + @param f the field to read + @param[out] val the field value + @return the field value + */ + static String *get_field_varchar_utf8(Field *f, String *val); + protected: /** Read the current row values. @@ -84,25 +168,32 @@ protected: unsigned char *new_buf, Field **fields); /** + Delete a row. + @param table Table handle + @param buf Row buffer + @param fields Table fields + */ + virtual int delete_row_values(TABLE *table, const unsigned char *buf, + Field **fields); + + /** Constructor. @param share table share @param pos address of the m_pos position member */ PFS_engine_table(const PFS_engine_table_share *share, void *pos) - : m_share_ptr(share), m_pos_ptr(pos) + : m_share_ptr(share), m_pos_ptr(pos), + m_normalizer(NULL), m_class_type(PFS_CLASS_NONE) {} - void set_field_ulong(Field *f, ulong value); - void set_field_ulonglong(Field *f, ulonglong value); - void set_field_varchar_utf8(Field *f, const char* str, uint len); - void set_field_enum(Field *f, ulonglong value); - - ulonglong get_field_enum(Field *f); - /** Table share. */ const PFS_engine_table_share *m_share_ptr; /** Opaque pointer to the m_pos position of this cursor. */ void *m_pos_ptr; + /** Current normalizer */ + time_normalizer *m_normalizer; + /** Current class type */ + enum PFS_class_type m_class_type; }; /** Callback to open a table. */ @@ -112,6 +203,8 @@ typedef int (*pfs_write_row_t)(TABLE *table, unsigned char *buf, Field **fields); /** Callback to delete all rows. */ typedef int (*pfs_delete_all_rows_t)(void); +/** Callback to get a row count. */ +typedef ha_rows (*pfs_get_row_count_t)(void); /** A PERFORMANCE_SCHEMA table share. @@ -123,6 +216,10 @@ struct PFS_engine_table_share void check_one_table(THD *thd); static void init_all_locks(void); static void delete_all_locks(void); + /** Get the row count. */ + ha_rows get_row_count(void) const; + /** Write a row. */ + int write_row(TABLE *table, unsigned char *buf, Field **fields) const; /** Table name. */ LEX_STRING m_name; @@ -134,6 +231,8 @@ struct PFS_engine_table_share pfs_write_row_t m_write_row; /** Delete all rows function. */ pfs_delete_all_rows_t m_delete_all_rows; + /** Get rows count function. */ + pfs_get_row_count_t m_get_row_count; /** Number or records. This number does not need to be precise, @@ -151,6 +250,10 @@ struct PFS_engine_table_share bool m_checked; }; +/** + Privileges for read only tables. + The only operation allowed is SELECT. +*/ class PFS_readonly_acl : public ACL_internal_table_access { public: @@ -163,8 +266,13 @@ public: ACL_internal_access_result check(ulong want_access, ulong *save_priv) const; }; +/** Singleton instance of PFS_readonly_acl. */ extern PFS_readonly_acl pfs_readonly_acl; +/** + Privileges for truncatable tables. + Operations allowed are SELECT and TRUNCATE. +*/ class PFS_truncatable_acl : public ACL_internal_table_access { public: @@ -177,8 +285,13 @@ public: ACL_internal_access_result check(ulong want_access, ulong *save_priv) const; }; +/** Singleton instance of PFS_truncatable_acl. */ extern PFS_truncatable_acl pfs_truncatable_acl; +/** + Privileges for updatable tables. + Operations allowed are SELECT and UPDATE. +*/ class PFS_updatable_acl : public ACL_internal_table_access { public: @@ -191,8 +304,13 @@ public: ACL_internal_access_result check(ulong want_access, ulong *save_priv) const; }; +/** Singleton instance of PFS_updatable_acl. */ extern PFS_updatable_acl pfs_updatable_acl; +/** + Privileges for editable tables. + Operations allowed are SELECT, INSERT, UPDATE, DELETE and TRUNCATE. +*/ class PFS_editable_acl : public ACL_internal_table_access { public: @@ -205,8 +323,12 @@ public: ACL_internal_access_result check(ulong want_access, ulong *save_priv) const; }; +/** Singleton instance of PFS_editable_acl. */ extern PFS_editable_acl pfs_editable_acl; +/** + Privileges for unknown tables. +*/ class PFS_unknown_acl : public ACL_internal_table_access { public: @@ -219,6 +341,7 @@ public: ACL_internal_access_result check(ulong want_access, ulong *save_priv) const; }; +/** Singleton instance of PFS_unknown_acl. */ extern PFS_unknown_acl pfs_unknown_acl; /** Position of a cursor, for simple iterations. */ @@ -227,20 +350,34 @@ struct PFS_simple_index /** Current row index. */ uint m_index; + /** + Constructor. + @param index the index initial value. + */ PFS_simple_index(uint index) : m_index(index) {} + /** + Set this index at a given position. + @param other a position + */ void set_at(const struct PFS_simple_index *other) { m_index= other->m_index; } + /** + Set this index after a given position. + @param other a position + */ void set_after(const struct PFS_simple_index *other) { m_index= other->m_index + 1; } + /** Set this index to the next record. */ void next(void) { m_index++; } }; +/** Position of a double cursor, for iterations using 2 nested loops. */ struct PFS_double_index { /** Outer index. */ @@ -248,16 +385,29 @@ struct PFS_double_index /** Current index within index_1. */ uint m_index_2; + /** + Constructor. + @param index_1 the first index initial value. + @param index_2 the second index initial value. + */ PFS_double_index(uint index_1, uint index_2) : m_index_1(index_1), m_index_2(index_2) {} + /** + Set this index at a given position. + @param other a position + */ void set_at(const struct PFS_double_index *other) { m_index_1= other->m_index_1; m_index_2= other->m_index_2; } + /** + Set this index after a given position. + @param other a position + */ void set_after(const struct PFS_double_index *other) { m_index_1= other->m_index_1; @@ -265,6 +415,7 @@ struct PFS_double_index } }; +/** Position of a triple cursor, for iterations using 3 nested loops. */ struct PFS_triple_index { /** Outer index. */ @@ -274,10 +425,20 @@ struct PFS_triple_index /** Current index within index_2. */ uint m_index_3; + /** + Constructor. + @param index_1 the first index initial value. + @param index_2 the second index initial value. + @param index_3 the third index initial value. + */ PFS_triple_index(uint index_1, uint index_2, uint index_3) : m_index_1(index_1), m_index_2(index_2), m_index_3(index_3) {} + /** + Set this index at a given position. + @param other a position + */ void set_at(const struct PFS_triple_index *other) { m_index_1= other->m_index_1; @@ -285,6 +446,10 @@ struct PFS_triple_index m_index_3= other->m_index_3; } + /** + Set this index after a given position. + @param other a position + */ void set_after(const struct PFS_triple_index *other) { m_index_1= other->m_index_1; @@ -293,22 +458,6 @@ struct PFS_triple_index } }; -struct PFS_instrument_view_constants -{ - static const uint VIEW_MUTEX= 1; - static const uint VIEW_RWLOCK= 2; - static const uint VIEW_COND= 3; - static const uint VIEW_FILE= 4; -}; - -struct PFS_object_view_constants -{ - static const uint VIEW_TABLE= 1; - static const uint VIEW_EVENT= 2; - static const uint VIEW_PROCEDURE= 3; - static const uint VIEW_FUNCTION= 4; -}; - bool pfs_show_status(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat); |