MySQL 9.6.0
Source Code Documentation
dictionary_client.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2025, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef DD_CACHE__DICTIONARY_CLIENT_INCLUDED
25#define DD_CACHE__DICTIONARY_CLIENT_INCLUDED
26
27#include <assert.h>
28#include <stddef.h>
29#include <functional>
30#include <memory>
31#include <string>
32#include <vector>
33
34#include "my_compiler.h"
35
36#include "object_registry.h" // Object_registry
37#include "sql/dd/object_id.h"
38#include "sql/dd/string_type.h"
39#include "sql/mdl.h"
40
41class THD;
42struct LEX_USER;
43
44namespace dd {
45class Schema;
46class Table;
47class Entity_object;
48} // namespace dd
49
50namespace dd {
51namespace cache {
52
53class SPI_lru_cache;
54
55/**
56 A smart-pointer for managing an SPI_lru_cache even when it is only
57 forward declared. Automatically allocated cache with new, and assigns
58 m_spi_lru_cache to it, when dereferenced using non-const
59 operator->(). Destructor deletes the object pointed to by
60 m_spi_lru_cache.
61*/
64
65 public:
66 /** Calls delete on m_spi_lru_cache unless nullptr. */
68
69 /**
70 Creates cache on demand if m_spi_lru_cache is nullptr.
71 @return pointer to cache.
72 */
74
75 /**
76 Const overload which does not create cache on demand, but merely
77 returns the pointer.
78 @return pointer to cache (may be nullptr)
79 */
80 const SPI_lru_cache *operator->() const { return m_spi_lru_cache; }
81
82 /*
83 Predicate for nullptr.
84 @return true if points to valid cache, false otherwise.
85 */
86 bool is_nullptr() const { return (m_spi_lru_cache == nullptr); }
87};
88
89/**
90 Implementation of a dictionary client.
91
92 The dictionary client provides a unified interface to accessing dictionary
93 objects. The client is a member of the THD, and is typically used in
94 server code to access the dictionary. When we refer to "the user" below,
95 we mean the server code using the dictionary client.
96
97 The main task of the client is to access a shared cache to retrieve
98 dictionary objects. The shared cache, in its turn, will access the
99 dictionary tables if there is a cache miss.
100
101 To support cache eviction, the shared cache must keep track of which
102 clients that have acquired an object. When a client acquires an object
103 from the shared cache for the first time, it is added to a client local
104 object registry. Further acquisition of the same object from the client
105 will get the object from the client's registry. Thus, the usage tracking
106 in the shared cache only keep track of the number of clients currently
107 using the object, and hence, there must be an operation that complements
108 acquisition, to inform the shared cache that the object is not used
109 anymore. This complementing operation is called releasing the object.
110
111 To manage releasing objects, the Auto_releaser class provides some
112 support. When an auto releaser is instantiated, it will keep track of
113 the objects that are acquired from the shared cache in its lifetime.
114 Auto releasers may be nested or stacked, and the current releaser is
115 the one at the top of the stack. The auto releaser stack is associated
116 with a dictionary client instance. When the auto releaser goes out
117 of scope, it will release all objects that have been acquired from the
118 shared cache in its lifetime. Objects retrieved earlier than that will
119 be automatically released by a releaser further down the auto releaser
120 stack. For more coarse grained control, there is a release method that
121 will release all objects acquired by the client.
122
123 In addition to the auto releasers, the client has an object registry.
124 The registry holds pointers to all currently acquired objects. Thus,
125 the object registry is the union of the registers in the stack of
126 auto releasers. The client's object registry is used for looking up
127 objects, while the registers in the auto releasers are used for
128 releasing objects.
129
130 The client also has a second registry of objects with uncommitted changes.
131 These are objects acquired by acquire_for_modification() or registered
132 with register_uncommitted_object(). These objects are only present in
133 the local registry and not in the shared cache. Once registered, the
134 objects can also be retrieved with normal acquire(). This means that
135 a given client has a view which includes uncommitted changes made
136 using the same client, while other clients do not see these changes.
137
138 @note We must handle situations where an object is actually acquired from
139 the shared cache, while the dynamic cast to a subtype fails. We use
140 the auto release mechanism to achieve that.
141
142 @note When a dictionary client method returns true, indicating that an
143 error has occurred, the error has been reported, either by the
144 client itself, or by the dictionary subsystem.
145*/
146
147template <typename T>
148class Cache_element;
149
150#ifndef NDEBUG
151/** Data needed to check if an MDL is held. */
155};
156
157/** Tracks MDLs for shared DD object. The object pointer
158makes it easier to move the descriptor to a different AR or
159remove it when the corresponding object is moved/removed. */
162 const Entity_object *m_object = nullptr;
163};
164#endif /* not NDEBUG */
165
167 public:
168 /**
169 Class to help releasing and deleting objects.
170
171 This class keeps a register of shared objects that are automatically
172 released when the instance goes out of scope. When a new instance
173 is created, the encompassing dictionary client's current auto releaser
174 is replaced by this one, keeping a link to the old one. When the
175 auto releaser is deleted, it links the old releaser back in as the
176 client's current releaser.
177
178 Shared objects that are added to the auto releaser will be released when
179 the releaser is deleted. Only the dictionary client is allowed to add
180 objects to the auto releaser.
181
182 The usage pattern is that objects that are retrieved from the shared
183 dictionary cache are added to the current auto releaser. Objects that
184 are retrieved from the client's local object register are not added to
185 the auto releaser. Thus, when the releaser is deleted, it releases all
186 objects that have been retrieved from the shared cache during the
187 lifetime of the releaser.
188
189 Similarly the auto releaser maintains a list of objects created
190 by acquire_uncached(). These objects are owned by the Auto_releaser
191 and are deleted when the auto releaser goes out of scope.
192 */
193
195 friend class Dictionary_client;
196
197 private:
201
202#ifndef NDEBUG
203 /** Cache of MDL_keys which have been asserted to hold when acquiring,
204 and which should be re-checked before this releaser goes out of scope. */
205 std::vector<Release_lock_descriptor> m_release_locks;
206#endif /* not NDEBUG */
207
208 /**
209 Register an object to be auto released.
210
211 @tparam T Dictionary object type.
212 @param element Cache element to auto release.
213 */
214
215 template <typename T>
217 // Catch situations where we do not use a non-default releaser.
218 assert(m_prev != nullptr);
219 m_release_registry.put(element);
220 }
221
222 /**
223 Transfer an object from the current to the previous auto releaser.
224
225 @tparam T Dictionary object type.
226 @param object Dictionary object to transfer.
227 */
228
229 template <typename T>
230 void transfer_release(const T *object);
231
232 /**
233 Remove an element from some auto releaser down the chain.
234
235 Return a pointer to the releaser where the element was found.
236 Thus, the element may be re-inserted into the appropriate
237 auto releaser after e.g. changing the keys.
238
239 @tparam T Dictionary object type.
240 @param element Cache element to auto remove.
241
242 @return Pointer to the auto releaser where the object was signed up.
243 */
244
245 template <typename T>
247
248 // Create a new empty auto releaser. Used only by the Dictionary_client.
250
251 public:
252 /**
253 Create a new auto releaser and link it into the dictionary client
254 as the current releaser.
255
256 @param client Dictionary client for which to install this auto
257 releaser.
258 */
259
260 explicit Auto_releaser(Dictionary_client *client);
261
262 // Release all objects registered and restore previous releaser.
264
265 // Debug dump to stderr.
266 template <typename T>
267 void dump() const;
268 };
269
270 private:
271 std::vector<Entity_object *> m_uncached_objects; // Objects to be deleted.
272 Object_registry m_registry_committed; // Registry of committed objects.
273 Object_registry m_registry_uncommitted; // Registry of uncommitted objects.
274 Object_registry m_registry_dropped; // Registry of dropped objects.
275 THD *m_thd; // Thread context, needed for cache misses.
276 Auto_releaser m_default_releaser; // Default auto releaser.
277 Auto_releaser *m_current_releaser; // Current auto releaser.
278
279 /**
280 Se-private ids known not to exist in either TABLES or PARTITIONS
281 or both.
282 */
284
285 private:
286 /**
287 Get a dictionary object.
288
289 The operation retrieves a dictionary object by one of its keys from the
290 cache and returns it through the object parameter. If the object is
291 already present in the client's local object registry, it is fetched
292 from there. Otherwise, it is fetched from the shared cache (possibly
293 involving a cache miss), and eventually added to the local object
294 registry.
295
296 If no object is found for the given key, NULL is returned. The shared
297 cache owns the returned object, i.e., the caller must not delete it.
298 After using the object(s), the user must release it using one of the
299 release mechanisms described earlier.
300
301 The reference counter for the object is incremented if the object is
302 retrieved from the shared cache. If the object was present in the local
303 registry, the reference counter stays the same. A cache miss is handled
304 transparently by the shared cache.
305
306 @note This function must be called with type T being the same as
307 T::Cache_partition. Dynamic casting to the actual subtype
308 must be done at an outer level.
309
310 @tparam K Key type.
311 @tparam T Dictionary object type.
312 @param key Key to use for looking up the object.
313 @param [out] object Object pointer, if an object exists, otherwise NULL.
314 @param [out] local_committed
315 Whether the object was read from the local
316 committed object registry.
317 @param [out] local_uncommitted
318 Whether the object was read from the local
319 uncommitted registry.
320
321 @retval false No error.
322 @retval true Error (from handling a cache miss).
323 */
324
325 template <typename K, typename T>
326 [[nodiscard]] bool acquire(const K &key, const T **object,
327 bool *local_committed, bool *local_uncommitted);
328
329 /**
330 Get an uncommitted dictionary object that can be modified safely.
331
332 The difference between this method and acquire(), is that this method
333 only looks in the local registry of uncommitted objects. That is, object
334 created by acquire_for_modification() or registered with
335 register_uncommitted_object(). It will not access the shared cache.
336 Objects that have been dropped are returned as nullptr, but
337 with the value of the parameter 'dropped' set to 'true'.
338
339 @tparam K Key type.
340 @tparam T Dictionary object type.
341 @param key Key to use for looking up the object.
342 @param [out] object Object pointer, if an object exists, otherwise NULL.
343 @param [out] dropped Object exists, but has been dropped and has not yet
344 committed. In this case, 'object' is set to nullptr.
345 */
346
347 template <typename K, typename T>
348 void acquire_uncommitted(const K &key, T **object, bool *dropped);
349
350 /**
351 Mark all objects of a certain type as not being used by this client.
352
353 This function is called with the client's own object registry, or with
354 the registry of an auto releaser (which will contain a subset of the
355 objects in the client's object registry).
356
357 The function will release all objects of a given type in the registry
358 submitted.The objects must be present and in use. If the objects become
359 unused, they are added to the free list in the shared cache, which is
360 then rectified to enforce its capacity constraints. The objects are also
361 removed from the client's object registry.
362
363 @tparam T Dictionary object type.
364 @param registry Object registry tp release from.
365
366 @return Number of objects released.
367 */
368
369 template <typename T>
370 size_t release(Object_registry *registry);
371
372 /**
373 Release all objects in the submitted object registry.
374
375 This function will release all objects from the client's registry, or
376 from the registry of an auto releaser.
377
378 @param registry Object registry tp release from.
379
380 @return Number of objects released.
381 */
382
383 size_t release(Object_registry *registry);
384
385 /**
386 Register an uncached object to be auto deleted.
387
388 @tparam T Dictionary object type.
389 @param object Dictionary object to auto delete.
390 */
391
392 template <typename T>
393 void auto_delete(T *object) {
394#ifndef NDEBUG
395 // Make sure we do not sign up a shared object for auto delete.
398 static_cast<const typename T::Cache_partition *>(object), &element);
399 assert(element == nullptr);
400
401 // Make sure we do not sign up an uncommitted object for auto delete.
403 static_cast<const typename T::Cache_partition *>(object), &element);
404 assert(element == nullptr);
405
406 // We must require a top level non-default releaser to ensure a
407 // predictable life span of the objects.
409#endif
410
411 m_uncached_objects.push_back(object);
412 }
413
414 /**
415 Remove an object from the auto delete vector.
416
417 @tparam T Dictionary object type.
418 @param object Dictionary object to keep.
419 */
420
421 template <typename T>
422 void no_auto_delete(T *object) {
423#ifndef NDEBUG
424 // Make sure the object has been registered as uncommitted.
427 static_cast<const typename T::Cache_partition *>(object), &element);
428 assert(element != nullptr);
429#endif
431 m_uncached_objects.end(), object),
432 m_uncached_objects.end());
433 }
434
435 /**
436 Transfer object ownership from caller to Dictionary_client,
437 and register the object as uncommitted.
438
439 This is intended for objects created by the caller that should
440 be managed by Dictionary_client. Transferring an object in this
441 way will make it accessible by calling acquire().
442
443 This method takes a non-const argument as it only makes
444 sense to register objects not acquired from the shared cache.
445
446 @tparam T Dictionary object type.
447 @param object Object to transfer ownership.
448 */
449
450 template <typename T>
451 void register_uncommitted_object(T *object);
452
453 /**
454 Transfer object ownership from caller to Dictionary_client,
455 and register the object as dropped.
456
457 This method is used internally by the Dictionary_client for
458 keeping track of dropped objects. This is needed before
459 transaction commit if an attempt is made to acquire the
460 dropped object, to avoid consulting the shared cache, which
461 might contaminate the cache due to a cache miss (handled with
462 isolation level READ_COMMITTED). Instead of consulting the
463 shared cache, this Dictionary_client will recognize that the
464 object is dropped, and return a nullptr.
465
466 This method takes a non-const argument as it only makes
467 sense to register objects not acquired from the shared cache.
468
469 @tparam T Dictionary object type.
470 @param object Object to transfer ownership.
471 */
472
473 template <typename T>
474 void register_dropped_object(T *object);
475
476 /**
477 Remove the uncommitted objects from the client and (depending
478 on the parameter) put them into the shared cache,
479 thereby making them visible to other clients. Should be called
480 after commit to disk but before metadata locks are released.
481
482 Can also be called after rollback in order to explicitly throw
483 the modified objects away before making any actions to compensate
484 for a partially completed statement. Note that uncommitted objects
485 are automatically removed once the topmost stack-allocated auto
486 releaser goes out of scope, so calling this function in case of
487 abort is only needed to make acquire return the old object again
488 later in the same statement.
489
490 @param commit_to_shared_cache
491 If true, uncommitted objects will
492 be put into the shared cache.
493 @tparam T Dictionary object type.
494 */
495
496 template <typename T>
497 void remove_uncommitted_objects(bool commit_to_shared_cache);
498
499 template <typename T>
500 using Const_ptr_vec = std::vector<const T *>;
501
502 /**
503 Fetch objects from DD tables that match the supplied key.
504
505 @tparam Object_type Type of object to fetch.
506 @param coll Vector to fill with objects.
507 @param object_key The search key. If key is not supplied, then
508 we do full index scan.
509
510 @return false Success.
511 @return true Failure (error is reported).
512 */
513
514 template <typename Object_type>
515 [[nodiscard]] bool fetch(Const_ptr_vec<Object_type> *coll,
516 const Object_key *object_key);
517
518 /**
519 Auxiliary function to retrieve an object by its object id without caching
520 it.It is responsibility of the caller to delete the retrieved object.
521 */
522 template <typename T>
523 bool acquire_uncached_impl(Object_id id, T **object);
524
525 /**
526 Auxiliary function to retrieve a possibly uncommitted object by its object
527 id without caching it. It is responsibility of the caller to delete the
528 retrieved object.
529 */
530 template <typename T>
532
533 public:
534 // Initialize an instance with a default auto releaser.
535 explicit Dictionary_client(THD *thd);
536
537 // Make sure all objects are released.
539
542 /**
543 Retrieve an object by its object id.
544
545 @tparam T Dictionary object type.
546 @param id Object id to retrieve.
547 @param [out] object Dictionary object, if present; otherwise NULL.
548
549 @retval false No error.
550 @retval true Error (from handling a cache miss).
551 */
553
554 template <typename T>
555 [[nodiscard]] bool acquire(Object_id id, const T **object);
556
557 /**
558 Retrieve an object by its object id.
559
560 This function returns a cloned object that can be modified.
561
562 @tparam T Dictionary object type.
563 @param id Object id to retrieve.
564 @param [out] object Dictionary object, if present; otherwise NULL.
565
566 @retval false No error.
567 @retval true Error (from handling a cache miss).
568 */
569
570 template <typename T>
571 [[nodiscard]] bool acquire_for_modification(Object_id id, T **object);
572
573 /**
574 Retrieve an object by its object id without caching it.
575
576 The object is not cached but owned by the dictionary client, who
577 makes sure it is deleted. The object must not be released, and may not
578 be used as a parameter to the other dictionary client methods since it is
579 not known by the object registry.
580
581 @tparam T Dictionary object type.
582 @param id Object id to retrieve.
583 @param [out] object Dictionary object, if present; otherwise NULL.
584
585 @retval false No error.
586 @retval true Error (from reading the dictionary tables).
587 */
588
589 template <typename T>
590 [[nodiscard]] bool acquire_uncached(Object_id id, T **object);
591
592 /**
593 Retrieve an object by its object id without caching it.
594
595 The object is not cached and owned by the caller through unique_ptr
596 it provides. The object may not be used as a parameter to the other
597 dictionary client methods since it is not known by the object registry.
598
599 @tparam T Dictionary object type.
600 @param id Object id to retrieve.
601 @param [out] object_ptr Smart pointer with dictionary object,
602 if present or with nullptr otherwise.
603
604 @retval false No error.
605 @retval true Error (from reading the dictionary tables).
606 */
607 template <typename T>
608 [[nodiscard]] bool acquire_uncached(Object_id id,
609 std::unique_ptr<T> *object_ptr);
610
611 /**
612 Retrieve a possibly uncommitted object by its object id without caching it.
613
614 The object is not cached but owned by the dictionary client, who
615 makes sure it is deleted. The object must not be released, and may not
616 be used as a parameter to the other dictionary client methods since it is
617 not known by the object registry.
618
619 When the object is read from the persistent tables, the transaction
620 isolation level is READ UNCOMMITTED. This is necessary to be able to
621 read uncommitted data from an earlier stage of the same session.
622
623 @tparam T Dictionary object type.
624 @param id Object id to retrieve.
625 @param [out] object Dictionary object, if present; otherwise nullptr.
626
627 @retval false No error.
628 @retval true Error (from reading the dictionary tables).
629 */
630
631 template <typename T>
632 [[nodiscard]] bool acquire_uncached_uncommitted(Object_id id, T **object);
633
634 /**
635 Retrieve a possibly uncommitted object by its object id without caching it.
636
637 The object is not cached and owned by the caller through unique_ptr
638 it provides. The object may not be used as a parameter to the other
639 dictionary client methods since it is not known by the object registry.
640
641 When the object is read from the persistent tables, the transaction
642 isolation level is READ UNCOMMITTED. This is necessary to be able to
643 read uncommitted data from an earlier stage of the same session.
644
645 @tparam T Dictionary object type.
646 @param id Object id to retrieve.
647 @param [out] object_ptr Smart pointer with dictionary object,
648 if present or with nullptr otherwise.
649
650 @retval false No error.
651 @retval true Error (from reading the dictionary tables).
652 */
653 template <typename T>
654 [[nodiscard]] bool acquire_uncached_uncommitted(
655 Object_id id, std::unique_ptr<T> *object_ptr);
656
657 /**
658 Retrieve an object by its name.
659
660 @tparam T Dictionary object type.
661 @param object_name Name of the object.
662 @param [out] object Dictionary object, if present; otherwise NULL.
663
664 @retval false No error.
665 @retval true Error (from handling a cache miss).
666 */
667
668 template <typename T>
669 [[nodiscard]] bool acquire(const String_type &object_name, const T **object);
670
671 /**
672 Retrieve an object by its name.
673
674 This function returns a cloned object that can be modified.
675
676 @tparam T Dictionary object type.
677 @param object_name Name of the object.
678 @param [out] object Dictionary object, if present; otherwise NULL.
679
680 @retval false No error.
681 @retval true Error (from handling a cache miss).
682 */
683
684 template <typename T>
685 [[nodiscard]] bool acquire_for_modification(const String_type &object_name,
686 T **object);
687
688 /**
689 Retrieve an object by its schema- and object name.
690
691 @note We will acquire an IX-lock on the schema name unless we already
692 have one. This is needed for proper synchronization with schema
693 DDL in cases where the table does not exist, and where the
694 indirect synchronization based on table names therefore will not
695 apply.
696
697 @todo TODO: We should change the MDL acquisition (see above) for a more
698 long term solution.
699
700 @tparam T Dictionary object type.
701 @param schema_name Name of the schema containing the object.
702 @param object_name Name of the object.
703 @param [out] object Dictionary object, if present; otherwise NULL.
704
705 @retval false No error.
706 @retval true Error (from handling a cache miss, or from
707 failing to get an MDL lock).
708 */
709
710 template <typename T>
711 [[nodiscard]] bool acquire(const String_type &schema_name,
712 const String_type &object_name, const T **object);
713
714 /**
715 Retrieve an object by its schema- and object name.
716
717 This function returns a cloned object that can be modified.
718
719 @note We will acquire an IX-lock on the schema name unless we already
720 have one. This is needed for proper synchronization with schema
721 DDL in cases where the table does not exist, and where the
722 indirect synchronization based on table names therefore will not
723 apply.
724
725 @todo TODO: We should change the MDL acquisition (see above) for a more
726 long term solution.
727
728 @tparam T Dictionary object type.
729 @param schema_name Name of the schema containing the object.
730 @param object_name Name of the object.
731 @param [out] object Dictionary object, if present; otherwise NULL.
732
733 @retval false No error.
734 @retval true Error (from handling a cache miss, or from
735 failing to get an MDL lock).
736 */
737
738 template <typename T>
739 [[nodiscard]] bool acquire_for_modification(const String_type &schema_name,
740 const String_type &object_name,
741 T **object);
742
743 /**
744 Retrieve an object by its schema- and object name.
745
746 @note We will acquire an IX-lock on the schema name unless we already
747 have one. This is needed for proper synchronization with schema
748 DDL in cases where the table does not exist, and where the
749 indirect synchronization based on table names therefore will not
750 apply.
751
752 @note This is a variant of the method above asking for an object of type
753 T, and hence using T's functions for updating name keys etc.
754 This function, however, returns the instance pointed to as type
755 T::Cache_partition to ease handling of various subtypes
756 of the same base type.
757
758 @todo TODO: We should change the MDL acquisition (see above) for a more
759 long term solution.
760
761 @tparam T Dictionary object type.
762 @param schema_name Name of the schema containing the object.
763 @param object_name Name of the object.
764 @param [out] object Dictionary object, if present; otherwise NULL.
765
766 @retval false No error.
767 @retval true Error (from handling a cache miss, or from
768 failing to get an MDL lock).
769 */
770
771 template <typename T>
772 [[nodiscard]] bool acquire(const String_type &schema_name,
773 const String_type &object_name,
774 const typename T::Cache_partition **object);
775
776 /**
777 Retrieve an object by its schema- and object name.
778
779 This function returns a cloned object that can be modified.
780
781 @note We will acquire an IX-lock on the schema name unless we already
782 have one. This is needed for proper synchronization with schema
783 DDL in cases where the table does not exist, and where the
784 indirect synchronization based on table names therefore will not
785 apply.
786
787 @note This is a variant of the method above asking for an object of type
788 T, and hence using T's functions for updating name keys etc.
789 This function, however, returns the instance pointed to as type
790 T::Cache_partition to ease handling of various subtypes
791 of the same base type.
792
793 @todo TODO: We should change the MDL acquisition (see above) for a more
794 long term solution.
795
796 @tparam T Dictionary object type.
797 @param schema_name Name of the schema containing the object.
798 @param object_name Name of the object.
799 @param [out] object Dictionary object, if present; otherwise NULL.
800
801 @retval false No error.
802 @retval true Error (from handling a cache miss, or from
803 failing to get an MDL lock).
804 */
805
806 template <typename T>
807 [[nodiscard]] bool acquire_for_modification(
808 const String_type &schema_name, const String_type &object_name,
809 typename T::Cache_partition **object);
810
811 /**
812 Retrieve a table object by its se private id.
813
814 @param engine Name of the engine storing the table.
815 @param se_private_id SE private id of the table.
816 @param [out] table Table object, if present; otherwise NULL.
817 @param skip_spi_cache Optionally skip looking into the missing
818 SE private ID cache. Defaults to false.
819
820 @note The object must be acquired uncached since we cannot acquire a
821 metadata lock in advance since we do not know the table name.
822 Thus, the returned table object is owned by the caller, who must
823 make sure it is deleted.
824
825 @retval false No error or if object was not found.
826 @retval true Error (e.g. from reading DD tables, or if an
827 object of a wrong type was found).
828 */
829
831 const String_type &engine, Object_id se_private_id, Table **table,
832 bool skip_spi_cache = false);
833
834 /**
835 Retrieve a table object by its partition se private id.
836
837 @param engine Name of the engine storing the table.
838 @param se_partition_id SE private id of the partition.
839 @param [out] table Table object, if present; otherwise NULL.
840
841 @retval false No error or if object was not found.
842 @retval true Error (from handling a cache miss).
843 */
844
846 const String_type &engine, Object_id se_partition_id, Table **table);
847
848 /**
849 Retrieve schema and table name by the se private id of the table.
850
851 @param engine Name of the engine storing the table.
852 @param se_private_id SE private id of the table.
853 @param [out] schema_name Name of the schema containing the table.
854 @param [out] table_name Name of the table.
855
856 @retval false No error OR if object was not found.
857 The OUT params will be set to empty
858 string when object is not found.
859 @retval true Error.
860 */
861
862 [[nodiscard]] bool get_table_name_by_se_private_id(const String_type &engine,
863 Object_id se_private_id,
864 String_type *schema_name,
866
867 /**
868 Retrieve schema and table name by the se private id of the partition.
869
870 @param engine Name of the engine storing the table.
871 @param se_partition_id SE private id of the table partition.
872 @param [out] schema_name Name of the schema containing the table.
873 @param [out] table_name Name of the table.
874
875 @retval false No error or if object was not found.
876 The OUT params will be set to empty
877 string when object is not found.
878 @retval true Error.
879 */
880
882 const String_type &engine, Object_id se_partition_id,
883 String_type *schema_name, String_type *table_name);
884
885 /**
886 Retrieve a table name of a given trigger name and schema.
887
888 @param schema Schema containing the trigger.
889 @param trigger_name Name of the trigger.
890 @param [out] table_name Name of the table for which
891 trigger belongs to. Empty string if
892 there is no such trigger.
893
894 @retval false No error.
895 @retval true Error.
896 */
897
898 [[nodiscard]] bool get_table_name_by_trigger_name(
899 const Schema &schema, const String_type &trigger_name,
901
902 /**
903 Check if schema contains foreign key with specified name.
904
905 @param schema Schema containing the foreign key.
906 @param foreign_key_name Name of the foreign key.
907 @param [out] exists Set to true if foreign key with
908 the name provided exists in the
909 schema, false otherwise.
910
911 @retval false No error.
912 @retval true Error.
913 */
914
915 [[nodiscard]] bool check_foreign_key_exists(
916 const Schema &schema, const String_type &foreign_key_name, bool *exists);
917
918 /**
919 Check if schema contains check constraint with specified name.
920
921 @param schema Schema containing the check constraint.
922 @param check_cons_name Name of the check constraint.
923 @param [out] exists Set to true if check constraint with
924 the name provided exists in the
925 schema, false otherwise.
926
927 @retval false No error.
928 @retval true Error.
929 */
930
931 bool check_constraint_exists(const Schema &schema,
932 const String_type &check_cons_name,
933 bool *exists);
934
935 /**
936 Fetch the names of the components in the schema. Hidden components are
937 ignored. E.g., Object with dd::Table::hidden() == true will be ignored.
938
939 @tparam T Type of object to retrieve names for.
940 @param schema Schema for which to get component names.
941 @param [out] names An std::vector containing all object names.
942
943 @return true Failure (error is reported).
944 @return false Success.
945 */
946
947 template <typename T>
948 [[nodiscard]] bool fetch_schema_component_names(
949 const Schema *schema, std::vector<String_type> *names) const;
950
951 /**
952 Fetch the names of the tables in the schema belonging to specific
953 storage engine. E.g., Object with dd::Table::hidden() == true will be
954 ignored.
955
956 @param schema Schema for which to get component names.
957 @param engine Engine name of tables to match.
958 @param [out] names An std::vector containing all object names.
959
960 @return true Failure (error is reported).
961 @return false Success.
962 */
963
964 [[nodiscard]] bool fetch_schema_table_names_by_engine(
965 const Schema *schema, const String_type &engine,
966 std::vector<String_type> *names) const;
967
968 /**
969 Fetch the names of the server tables in the schema. Ignore tables
970 hidden by SE.
971
972 @param schema Schema for which to get component names.
973 @param [out] names An std::vector containing all object names.
974
975 @return true Failure (error is reported).
976 @return false Success.
977 */
978
980 const Schema *schema, std::vector<String_type> *names) const;
981
982 /** TODO.dt */
984 const Schema *schema, std::vector<String_type> *names) const;
985
986 /**
987 Fetch all global component ids of the given type.
988
989 @tparam T Type of components to get.
990 @param [out] ids An std::vector containing all component ids.
991
992 @return true Failure (error is reported).
993 @return false Success.
994 */
995
996 template <typename T>
997 [[nodiscard]] bool fetch_global_component_ids(
998 std::vector<Object_id> *ids) const;
999
1000 /**
1001 Fetch all global component names of the given type.
1002
1003 @tparam T Type of components to get.
1004 @param [out] names An std::vector containing all component names.
1005
1006 @return true Failure (error is reported).
1007 @return false Success.
1008 */
1009
1010 template <typename T>
1011 [[nodiscard]] bool fetch_global_component_names(
1012 std::vector<String_type> *names) const;
1013
1014 /**
1015 Execute the submitted lambda function for each entity of the given type
1016 selected by the submitted key. If the lambda returns true, iteration
1017 stops and the function returns.
1018
1019 @tparam Object_type Entity type to examine.
1020 @param object_key Key to use for selecting entities.
1021 @param processor Lambda to execute for each entity.
1022 @return true Failure (error is reported unless the lambda
1023 returned true).
1024 @return false Success.
1025 */
1026
1027 template <typename Object_type>
1028 [[nodiscard]] bool foreach (
1029 const Object_key *object_key,
1030 std::function<bool(std::unique_ptr<Object_type> &)> const &processor)
1031 const;
1032
1033 /**
1034 Fetch all components in the schema.
1035
1036 @tparam T Type of components to get.
1037 @param schema Schema for which to get components.
1038 @param [out] coll An std::vector containing all components.
1039
1040 @return true Failure (error is reported).
1041 @return false Success.
1042 */
1043
1044 template <typename T>
1045 [[nodiscard]] bool fetch_schema_components(const Schema *schema,
1046 Const_ptr_vec<T> *coll);
1047
1048 /**
1049 Fetch all global components of the given type.
1050
1051 @tparam T Type of components to get.
1052 @param [out] coll An std::vector containing all components.
1053
1054 @return true Failure (error is reported).
1055 @return false Success.
1056 */
1057
1058 template <typename T>
1059 [[nodiscard]] bool fetch_global_components(Const_ptr_vec<T> *coll);
1060
1061 /**
1062 Check if a user is referenced as definer by some object of the given type.
1063
1064 @tparam T Type of dictionary objects to check.
1065 @param user User name, including @ and host.
1066 @param [out] is_definer True if the user is referenced as definer
1067 by some object.
1068
1069 @return true Failure (error is reported, is_definer is undefined).
1070 @return false Success.
1071 */
1072 template <typename T>
1073 [[nodiscard]] bool is_user_definer(const LEX_USER &user,
1074 bool *is_definer) const;
1075
1076 /**
1077 Fetch Object ids of all the views referencing base table/ view/ stored
1078 function name specified in "schema"."name". The views are retrieved
1079 using READ_UNCOMMITTED reads as the views could be changed by the same
1080 statement (e.g. multi-table/-view RENAME TABLE).
1081
1082 @tparam T Type of the object (View_table/View_routine)
1083 to retrieve view names for.
1084 @param schema Schema name.
1085 @param tbl_or_sf_name Base table/ View/ Stored function name.
1086 @param[out] view_ids Vector to store Object ids of all the views
1087 referencing schema.name.
1088
1089 @return true Failure (error is reported).
1090 @return false Success.
1091 */
1092 template <typename T>
1093 [[nodiscard]] bool fetch_referencing_views_object_id(
1094 const char *schema, const char *tbl_or_sf_name,
1095 std::vector<Object_id> *view_ids) const;
1096
1097 /**
1098 Fetch the names of tables (children) which have foreign keys
1099 defined to the given table (parent).
1100
1101 @param parent_schema Schema name of parent table.
1102 @param parent_name Table name of parent table.
1103 @param parent_engine Storage engine of parent table.
1104 @param uncommitted Use READ_UNCOMMITTED isolation.
1105 @param[out] children_schemas Schema names of child tables.
1106 @param[out] children_names Table names of child tables.
1107
1108 @return true Failure (error is reported).
1109 @return false Success.
1110
1111 @note Child tables are identified by matching pairs of names.
1112
1113 @note This is a temporary workaround until WL#6049. This function will
1114 *not* take any locks protecting against DDL changes. So the returned
1115 names could become invalid at any time - e.g. due to DROP DATABASE,
1116 DROP TABLE or DROP FOREIGN KEY.
1117 */
1118
1119 [[nodiscard]] bool fetch_fk_children_uncached(
1120 const String_type &parent_schema, const String_type &parent_name,
1121 const String_type &parent_engine, bool uncommitted,
1122 std::vector<String_type> *children_schemas,
1123 std::vector<String_type> *children_names);
1124
1125 /**
1126 Invalidate a cache entry.
1127
1128 This function will acquire a table object based on the schema qualified
1129 table name, and call 'invalidate(table_object)'.
1130
1131 @note This function only applies to tables yet.
1132
1133 @param schema_name Name of the schema containing the table.
1134 @param table_name Name of the table.
1135
1136 @retval false No error.
1137 @retval true Error (from handling a cache miss, or from
1138 failing to get an MDL lock).
1139 */
1140
1141 [[nodiscard]] bool invalidate(const String_type &schema_name,
1142 const String_type &table_name);
1143
1144 /**
1145 Invalidate a cache entry.
1146
1147 This function will remove and delete an object from the shared cache,
1148 based on the id of the object. If the object id is present in the local
1149 object registry and the auto releaser, it will be removed from there as
1150 well.
1151
1152 @note There is no particular consideration of already dropped or modified
1153 objects in this method.
1154
1155 @tparam T Dictionary object type.
1156 @param object Object to be invalidated.
1157 */
1158
1159 template <typename T>
1160 void invalidate(const T *object);
1161
1162 /**
1163 Remove and delete an object from the cache and the dd tables.
1164
1165 This function will remove the object from the local registry as well as
1166 the shared cache. This means that all keys associated with the object will
1167 be removed from the maps, and the cache element wrapper will be deleted.
1168 Afterwards, the object pointed to will also be deleted, and finally, the
1169 corresponding entry in the appropriate dd table is deleted. The object may
1170 not be accessed after calling this function.
1171
1172 @sa invalidate()
1173
1174 @note The object parameter is const since the contents of the object
1175 is not really changed, the object is just deleted. The method
1176 makes sure there is an exclusive meta data lock on the object
1177 name.
1178
1179 @note The argument to this function may come from acquire(), and may
1180 be an instance that is present in the uncommitted registry,
1181 or in the committed registry. These use cases are handled by
1182 the implementation of the function. The ownership of the
1183 'object' is not changed, instead, a clone is created and
1184 added to the dropped registry.
1185
1186 @tparam T Dictionary object type.
1187 @param object Object to be dropped.
1188
1189 @retval false The operation was successful.
1190 @retval true There was an error.
1191 */
1192
1193 template <typename T>
1194 [[nodiscard]] bool drop(const T *object);
1195
1196 /**
1197 Store a new dictionary object.
1198
1199 This function will write the object to the dd tables. The object is
1200 added neither to the dictionary client's object registry nor the shared
1201 cache.
1202
1203 @note A precondition is that the object has not been acquired from the
1204 shared cache. For storing an object which is already in the cache,
1205 please use update().
1206
1207 @note After calling store(), the submitted dictionary object can not be
1208 used for further calls to store(). It might be used as an argument
1209 to update(), but this is not recommended since calling update()
1210 will imply transferring object ownership to the dictionary client.
1211 Instead, please call 'acquire_for_modification()' to get a new
1212 object instance to use for modification and further updates.
1213
1214 @tparam T Dictionary object type.
1215 @param object Object to be stored.
1216
1217 @retval false The operation was successful.
1218 @retval true There was an error.
1219 */
1220
1221 template <typename T>
1222 [[nodiscard]] bool store(T *object);
1223
1224 /**
1225 Update a persisted dictionary object, but keep the shared cache unchanged.
1226
1227 This function will store a dictionary object to the DD tables after
1228 verifying that an object with the same id already exists. The old object,
1229 which may be present in the shared dictionary cache, is not modified. To
1230 make the changes visible in the shared cache, please call
1231 remove_uncommitted_objects().
1232
1233 @note A precondition is that the object has been acquired from the
1234 shared cache indirectly by acquire_for_modification(). For storing
1235 an object which is not already in the cache, please use store().
1236
1237 @note The new_object pointer submitted to this function, is owned by the
1238 auto delete vector. When registering the new object as an uncommitted
1239 object, the object must be removed from the auto delete vector.
1240
1241 @tparam T Dictionary object type.
1242 @param new_object New object, not present in the cache, to be
1243 stored persistently.
1244
1245 @retval false The operation was successful.
1246 @retval true There was an error.
1247 */
1248
1249 template <typename T>
1250 [[nodiscard]] bool update(T *new_object);
1251
1252 /**
1253 Remove the uncommitted objects from the client.
1254
1255 Can also be used to explicitly throw the modified objects
1256 away before making any actions to compensate
1257 for a partially completed statement. Note that uncommitted objects
1258 are automatically removed once the topmost stack-allocated auto
1259 releaser goes out of scope, so calling this function in case of
1260 abort is only needed to make acquire return the old object again
1261 later in the same statement.
1262 */
1263
1265
1266 /**
1267 Remove the uncommitted objects from the client and put them into
1268 the shared cache, thereby making them visible to other clients.
1269 Should be called after commit to disk but before metadata locks
1270 are released.
1271 */
1272
1274
1275 /**
1276 Remove table statistics entries from mysql.table_stats and
1277 mysql.index_stats.
1278
1279 @param schema_name Schema name of the table
1280 @param table_name Table name of which stats should be cleaned.
1281
1282 @return true - on failure
1283 @return false - on success
1284 */
1285 [[nodiscard]] bool remove_table_dynamic_statistics(
1286 const String_type &schema_name, const String_type &table_name);
1287
1288 /**
1289 Debug dump of a partition of the client and its registry to stderr.
1290
1291 @tparam T Dictionary object type.
1292 */
1293 template <typename T>
1294 void dump() const;
1295};
1296
1297} // namespace cache
1298} // namespace dd
1299
1300// Functions declarations exported only to facilitate unit testing.
1304} // namespace dd_cache_unittest
1305
1306#endif // DD_CACHE__DICTIONARY_CLIENT_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:48
Definition: object_key.h:38
Definition: schema.h:64
Definition: table.h:47
Implementation of a dictionary client.
Definition: cache_element.h:69
Class to help releasing and deleting objects.
Definition: dictionary_client.h:194
void dump() const
Definition: dictionary_client.cc:601
Auto_releaser * m_prev
Definition: dictionary_client.h:200
~Auto_releaser()
Definition: dictionary_client.cc:514
std::vector< Release_lock_descriptor > m_release_locks
Cache of MDL_keys which have been asserted to hold when acquiring, and which should be re-checked bef...
Definition: dictionary_client.h:205
Auto_releaser * remove(Cache_element< T > *element)
Remove an element from some auto releaser down the chain.
Dictionary_client * m_client
Definition: dictionary_client.h:198
Object_registry m_release_registry
Definition: dictionary_client.h:199
Auto_releaser()
Definition: dictionary_client.cc:496
void transfer_release(const T *object)
Transfer an object from the current to the previous auto releaser.
Definition: dictionary_client.cc:446
void auto_release(Cache_element< T > *element)
Register an object to be auto released.
Definition: dictionary_client.h:216
Definition: dictionary_client.h:166
THD * m_thd
Definition: dictionary_client.h:275
bool acquire_uncached(Object_id id, T **object)
Retrieve an object by its object id without caching it.
Definition: dictionary_client.cc:960
Auto_releaser * m_current_releaser
Definition: dictionary_client.h:277
void dump() const
Debug dump of a partition of the client and its registry to stderr.
Definition: dictionary_client.cc:2749
bool fetch_referencing_views_object_id(const char *schema, const char *tbl_or_sf_name, std::vector< Object_id > *view_ids) const
Fetch Object ids of all the views referencing base table/ view/ stored function name specified in "sc...
Definition: dictionary_client.cc:2106
Object_registry m_registry_committed
Definition: dictionary_client.h:272
bool drop(const T *object)
Remove and delete an object from the cache and the dd tables.
Definition: dictionary_client.cc:2339
bool acquire_for_modification(Object_id id, T **object)
Retrieve an object by its object id.
Definition: dictionary_client.cc:897
bool fetch_global_components(Const_ptr_vec< T > *coll)
Fetch all global components of the given type.
Definition: dictionary_client.cc:2060
bool fetch_fk_children_uncached(const String_type &parent_schema, const String_type &parent_name, const String_type &parent_engine, bool uncommitted, std::vector< String_type > *children_schemas, std::vector< String_type > *children_names)
Fetch the names of tables (children) which have foreign keys defined to the given table (parent).
Definition: dictionary_client.cc:2152
Object_registry m_registry_dropped
Definition: dictionary_client.h:274
~Dictionary_client()
Definition: dictionary_client.cc:838
bool get_table_name_by_trigger_name(const Schema &schema, const String_type &trigger_name, String_type *table_name)
Retrieve a table name of a given trigger name and schema.
Definition: dictionary_client.cc:1666
bool check_foreign_key_exists(const Schema &schema, const String_type &foreign_key_name, bool *exists)
Check if schema contains foreign key with specified name.
Definition: dictionary_client.cc:1711
bool acquire(const K &key, const T **object, bool *local_committed, bool *local_uncommitted)
Get a dictionary object.
Definition: dictionary_client.cc:639
SPI_lru_cache_owner_ptr m_no_table_spids
Se-private ids known not to exist in either TABLES or PARTITIONS or both.
Definition: dictionary_client.h:283
Auto_releaser m_default_releaser
Definition: dictionary_client.h:276
std::vector< const T * > Const_ptr_vec
Definition: dictionary_client.h:500
bool fetch(Const_ptr_vec< Object_type > *coll, const Object_key *object_key)
Fetch objects from DD tables that match the supplied key.
Definition: dictionary_client.cc:2021
bool acquire_uncached_table_by_se_private_id(const String_type &engine, Object_id se_private_id, Table **table, bool skip_spi_cache=false)
Retrieve a table object by its se private id.
Definition: dictionary_client.cc:1342
bool is_user_definer(const LEX_USER &user, bool *is_definer) const
Check if a user is referenced as definer by some object of the given type.
Definition: dictionary_client.cc:2072
bool acquire_uncached_table_by_partition_se_private_id(const String_type &engine, Object_id se_partition_id, Table **table)
Retrieve a table object by its partition se private id.
Definition: dictionary_client.cc:1401
std::vector< Entity_object * > m_uncached_objects
Definition: dictionary_client.h:271
bool store(T *object)
Store a new dictionary object.
Definition: dictionary_client.cc:2374
bool foreach(const Object_key *object_key, std::function< bool(std::unique_ptr< Object_type > &)> const &processor) const
Execute the submitted lambda function for each entity of the given type selected by the submitted key...
Definition: dictionary_client.cc:1944
void commit_modified_objects()
Remove the uncommitted objects from the client and put them into the shared cache,...
Definition: dictionary_client.cc:2733
bool fetch_schema_table_names_not_hidden_by_se(const Schema *schema, std::vector< String_type > *names) const
Fetch the names of the server tables in the schema.
Definition: dictionary_client.cc:1853
bool fetch_global_component_names(std::vector< String_type > *names) const
Fetch all global component names of the given type.
Definition: dictionary_client.cc:1815
bool update(T *new_object)
Update a persisted dictionary object, but keep the shared cache unchanged.
Definition: dictionary_client.cc:2424
bool remove_table_dynamic_statistics(const String_type &schema_name, const String_type &table_name)
Remove table statistics entries from mysql.table_stats and mysql.index_stats.
Definition: dictionary_client.cc:1492
void remove_uncommitted_objects(bool commit_to_shared_cache)
Remove the uncommitted objects from the client and (depending on the parameter) put them into the sha...
Definition: dictionary_client.cc:2611
bool fetch_schema_component_names(const Schema *schema, std::vector< String_type > *names) const
Fetch the names of the components in the schema.
Definition: dictionary_client.cc:1931
bool fetch_schema_base_table_names_not_hidden_by_se(const Schema *schema, std::vector< String_type > *names) const
TODO.dt.
Definition: dictionary_client.cc:1866
void rollback_modified_objects()
Remove the uncommitted objects from the client.
Definition: dictionary_client.cc:2720
bool fetch_schema_components(const Schema *schema, Const_ptr_vec< T > *coll)
Fetch all components in the schema.
Definition: dictionary_client.cc:2044
bool invalidate(const String_type &schema_name, const String_type &table_name)
Invalidate a cache entry.
Definition: dictionary_client.cc:2238
void register_dropped_object(T *object)
Transfer object ownership from caller to Dictionary_client, and register the object as dropped.
Definition: dictionary_client.cc:2548
bool check_constraint_exists(const Schema &schema, const String_type &check_cons_name, bool *exists)
Check if schema contains check constraint with specified name.
Definition: dictionary_client.cc:1736
Object_registry m_registry_uncommitted
Definition: dictionary_client.h:273
void auto_delete(T *object)
Register an uncached object to be auto deleted.
Definition: dictionary_client.h:393
bool acquire_uncached_uncommitted(Object_id id, T **object)
Retrieve a possibly uncommitted object by its object id without caching it.
Definition: dictionary_client.cc:1025
bool fetch_schema_table_names_by_engine(const Schema *schema, const String_type &engine, std::vector< String_type > *names) const
Fetch the names of the tables in the schema belonging to specific storage engine.
Definition: dictionary_client.cc:1834
void acquire_uncommitted(const K &key, T **object, bool *dropped)
Get an uncommitted dictionary object that can be modified safely.
Definition: dictionary_client.cc:745
size_t release(Object_registry *registry)
Mark all objects of a certain type as not being used by this client.
Definition: dictionary_client.cc:784
bool acquire_uncached_uncommitted_impl(Object_id id, T **object)
Auxiliary function to retrieve a possibly uncommitted object by its object id without caching it.
Definition: dictionary_client.cc:977
void no_auto_delete(T *object)
Remove an object from the auto delete vector.
Definition: dictionary_client.h:422
bool get_table_name_by_se_private_id(const String_type &engine, Object_id se_private_id, String_type *schema_name, String_type *table_name)
Retrieve schema and table name by the se private id of the table.
Definition: dictionary_client.cc:1577
Dictionary_client(THD *thd)
Definition: dictionary_client.cc:828
bool acquire_uncached_impl(Object_id id, T **object)
Auxiliary function to retrieve an object by its object id without caching it.It is responsibility of ...
Definition: dictionary_client.cc:932
bool get_table_name_by_partition_se_private_id(const String_type &engine, Object_id se_partition_id, String_type *schema_name, String_type *table_name)
Retrieve schema and table name by the se private id of the partition.
Definition: dictionary_client.cc:1624
bool fetch_global_component_ids(std::vector< Object_id > *ids) const
Fetch all global component ids of the given type.
Definition: dictionary_client.cc:1795
void register_uncommitted_object(T *object)
Transfer object ownership from caller to Dictionary_client, and register the object as uncommitted.
Definition: dictionary_client.cc:2512
Object registry containing several maps.
Definition: object_registry.h:62
void put(Cache_element< T > *element)
Add a new element to the registry.
Definition: object_registry.h:279
void get(const K &key, Cache_element< T > **element) const
Get the element corresponding to the given key.
Definition: object_registry.h:263
A smart-pointer for managing an SPI_lru_cache even when it is only forward declared.
Definition: dictionary_client.h:62
SPI_lru_cache * m_spi_lru_cache
Definition: dictionary_client.h:63
~SPI_lru_cache_owner_ptr()
Calls delete on m_spi_lru_cache unless nullptr.
Definition: dictionary_client.cc:426
SPI_lru_cache * operator->()
Creates cache on demand if m_spi_lru_cache is nullptr.
Definition: dictionary_client.cc:432
bool is_nullptr() const
Definition: dictionary_client.h:86
const SPI_lru_cache * operator->() const
Const overload which does not create cache on demand, but merely returns the pointer.
Definition: dictionary_client.h:80
Inherit from an instantiation of the template to allow forward-declaring in Dictionary_client.
Definition: dictionary_client.cc:424
#define T
Definition: jit_executor_value.cc:373
Header for compiler-dependent features.
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
#define MY_COMPILER_CLANG_WORKAROUND_TPARAM_DOCBUG()
ignore -Wdocumentation compiler warnings for @tparam.
Definition: my_compiler.h:300
char * user
Definition: mysqladmin.cc:67
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
bool is_cached(const SPI_lru_cache_owner_ptr &cache, Object_id id, SPI_missing_type t)
Definition: dictionary_client.cc:439
Definition: dictionary_client.h:1301
void insert(dd::cache::SPI_lru_cache_owner_ptr &c, dd::Object_id id)
Definition: dictionary_client.cc:3077
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:44
unsigned long long Object_id
Definition: object_id.h:31
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
static mysql_service_status_t remove(reference_caching_channel channel, const char *implementation_name) noexcept
Definition: component.cc:137
const char * table_name
Definition: rules_table_service.cc:56
Define std::hash<Gtid>.
Definition: gtid.h:355
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2880
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2444
static int exists(node_address *name, node_list const *nodes, u_int with_uid)
Definition: node_list.cc:107
required string key
Definition: replication_asynchronous_connection_failover.proto:60
enum_mdl_type
Type of metadata lock request.
Definition: sql_lexer_yacc_state.h:106
@ MDL_TYPE_END
Definition: sql_lexer_yacc_state.h:238
Definition: table.h:2819
Metadata lock object key.
Definition: mdl.h:366
Data needed to check if an MDL is held.
Definition: dictionary_client.h:152
enum_mdl_type m_mdl_type
Definition: dictionary_client.h:154
MDL_key m_mdl_key
Definition: dictionary_client.h:153
Tracks MDLs for shared DD object.
Definition: dictionary_client.h:160
const Entity_object * m_object
Definition: dictionary_client.h:162
MDL_descriptor m_mdld
Definition: dictionary_client.h:161