MySQL 8.3.0
Source Code Documentation
locking_service.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef LOCKING_SERVICE_INCLUDED
24#define LOCKING_SERVICE_INCLUDED
25
26#include <stddef.h>
27
28#include "my_systime.h" // Timout_type
29#include "mysql/service_locking.h" // enum_locking_service_lock_type
30class THD;
31
32/**
33 Acquire locking service locks.
34
35 @param opaque_thd Thread handle. If NULL, current_thd will be used.
36 @param lock_namespace Namespace of the locks to acquire.
37 @param lock_names Array of names of the locks to acquire.
38 @param lock_num Number of elements in 'lock_names'.
39 @param lock_type Lock type to acquire. LOCKING_SERVICE_READ or _WRITE.
40 @param lock_timeout Number of seconds to wait before giving up.
41
42 @retval 1 Acquisition failed, error has been reported.
43 @retval 0 Acquisition successful, all locks acquired.
44
45 @note both lock_namespace and lock_names are limited to 64 characters max.
46 Names are compared using binary comparison.
47*/
49 const char *lock_namespace,
50 const char **lock_names, size_t lock_num,
51 enum enum_locking_service_lock_type lock_type,
52 Timeout_type lock_timeout);
53
54/**
55 Release all lock service locks taken by the given connection
56 in the given namespace.
57
58 @param opaque_thd Thread handle. If NULL, current_thd will be used.
59 @param lock_namespace Namespace of the locks to release.
60
61 @retval 1 Release failed, error has been reported.
62 @retval 0 Release successful, all locks acquired.
63*/
65 const char *lock_namespace);
66
67/**
68 Release all locking service locks taken by the given connection
69 in all namespaces.
70
71 @param thd Thread handle.
72*/
74
75#endif /* LOCKING_SERVICE_INCLUDED */
#define MYSQL_THD
Definition: backup_page_tracker.h:37
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
void release_all_locking_service_locks(THD *thd)
Release all locking service locks taken by the given connection in all namespaces.
Definition: locking_service.cc:166
int acquire_locking_service_locks(MYSQL_THD opaque_thd, const char *lock_namespace, const char **lock_names, size_t lock_num, enum enum_locking_service_lock_type lock_type, Timeout_type lock_timeout)
Acquire locking service locks.
Definition: locking_service.cc:109
int release_locking_service_locks(MYSQL_THD opaque_thd, const char *lock_namespace)
Release all lock service locks taken by the given connection in the given namespace.
Definition: locking_service.cc:149
Defines for getting and processing the current system type programmatically.
std::uint64_t Timeout_type
Type alias to reduce chance of conversion errors on timeout values.
Definition: my_systime.h:124
Implements mysql_locking_service_st.
enum_locking_service_lock_type
Types of locking service locks.
Definition: service_locking.h:51