diff options
Diffstat (limited to 'sql/mdl.h')
-rw-r--r-- | sql/mdl.h | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/sql/mdl.h b/sql/mdl.h index b084670e5c6..4659238e9f2 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -353,7 +353,7 @@ enum enum_mdl_duration { or "name". */ -class MDL_key +struct MDL_key { public: #ifdef HAVE_PSI_INTERFACE @@ -535,18 +535,23 @@ public: /** A lock is requested based on a fully qualified name and type. */ MDL_key key; + const char *m_src_file; + uint m_src_line; + public: static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } static void operator delete(void *, MEM_ROOT *) {} - void init(MDL_key::enum_mdl_namespace namespace_arg, + void init_with_source(MDL_key::enum_mdl_namespace namespace_arg, const char *db_arg, const char *name_arg, enum_mdl_type mdl_type_arg, - enum_mdl_duration mdl_duration_arg); - void init(const MDL_key *key_arg, enum_mdl_type mdl_type_arg, - enum_mdl_duration mdl_duration_arg); + enum_mdl_duration mdl_duration_arg, + const char *src_file, uint src_line); + void init_by_key_with_source(const MDL_key *key_arg, enum_mdl_type mdl_type_arg, + enum_mdl_duration mdl_duration_arg, + const char *src_file, uint src_line); /** Set type of lock request. Can be only applied to pending locks. */ inline void set_type(enum_mdl_type type_arg) { @@ -610,6 +615,12 @@ public: typedef void (*mdl_cached_object_release_hook)(void *); +#define MDL_REQUEST_INIT(R, P1, P2, P3, P4, P5) \ + (*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__) + +#define MDL_REQUEST_INIT_BY_KEY(R, P1, P2, P3) \ + (*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__) + /** An abstract class for inspection of a connected @@ -718,6 +729,11 @@ public: /** Implement MDL_wait_for_subgraph interface. */ virtual bool accept_visitor(MDL_wait_for_graph_visitor *dvisitor); virtual uint get_deadlock_weight() const; + /** + Status of lock request represented by the ticket as reflected in P_S. + */ + enum enum_psi_status { PENDING = 0, GRANTED, + PRE_ACQUIRE_NOTIFY, POST_RELEASE_NOTIFY }; private: friend class MDL_context; @@ -731,9 +747,15 @@ private: m_duration(duration_arg), #endif m_ctx(ctx_arg), - m_lock(NULL) + m_lock(NULL), + m_psi(NULL) {} + virtual ~MDL_ticket() + { + DBUG_ASSERT(m_psi == NULL); + } + static MDL_ticket *create(MDL_context *ctx_arg, enum_mdl_type type_arg #ifndef DBUG_OFF , enum_mdl_duration duration_arg @@ -760,6 +782,8 @@ private: */ MDL_lock *m_lock; + PSI_metadata_lock *m_psi; + private: MDL_ticket(const MDL_ticket &); /* not implemented */ MDL_ticket &operator=(const MDL_ticket &); /* not implemented */ |