Skip to content

Commit a062f62

Browse files
committed
Merge branch 'mysql-8.0' into mysql-trunk
2 parents 635ddab + ff5b2d4 commit a062f62

35 files changed

+261
-146
lines changed

Diff for: components/validate_password/validate_password_imp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -46,7 +46,7 @@ extern REQUIRES_SERVICE_PLACEHOLDER(component_sys_variable_unregister);
4646
extern REQUIRES_SERVICE_PLACEHOLDER(status_variable_registration);
4747
extern REQUIRES_SERVICE_PLACEHOLDER(mysql_thd_security_context);
4848
extern REQUIRES_SERVICE_PLACEHOLDER(mysql_security_context_options);
49-
extern REQUIRES_SERVICE_PLACEHOLDER(psi_memory_v1);
49+
extern REQUIRES_SERVICE_PLACEHOLDER(psi_memory_v2);
5050

5151
/**
5252
An implementation of the password_validation_service to validate password and

Diff for: include/my_alloc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ struct MEM_ROOT {
187187
* schema. Use when transferring responsibility for a MEM_ROOT from one thread
188188
* to another.
189189
*/
190-
void Claim();
190+
void Claim(bool claim);
191191

192192
/**
193193
* Deallocate all the RAM used. The MEM_ROOT itself continues to be valid,

Diff for: include/mysql.h.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
void my_net_local_init(struct NET *net);
191191
void net_end(struct NET *net);
192192
void net_clear(struct NET *net, bool check_buffer);
193-
void net_claim_memory_ownership(struct NET *net);
193+
void net_claim_memory_ownership(struct NET *net, bool claim);
194194
bool net_realloc(struct NET *net, size_t length);
195195
bool net_flush(struct NET *net);
196196
bool my_net_write(struct NET *net, const unsigned char *packet, size_t len);

Diff for: include/mysql/components/services/psi_memory.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#include <mysql/components/component_implementation.h>
2727
#include <mysql/components/services/psi_memory_service.h>
2828

29-
#define REQUIRES_PSI_MEMORY_SERVICE REQUIRES_SERVICE(psi_memory_v1)
29+
#define REQUIRES_PSI_MEMORY_SERVICE REQUIRES_SERVICE(psi_memory_v2)
3030
#define REQUIRES_PSI_MEMORY_SERVICE_PLACEHOLDER \
31-
REQUIRES_SERVICE_PLACEHOLDER(psi_memory_v1)
31+
REQUIRES_SERVICE_PLACEHOLDER(psi_memory_v2)
3232

3333
extern REQUIRES_PSI_MEMORY_SERVICE_PLACEHOLDER;
3434

35-
#define PSI_MEMORY_CALL(M) mysql_service_psi_memory_v1->M
35+
#define PSI_MEMORY_CALL(M) mysql_service_psi_memory_v2->M
3636

3737
#endif /* COMPONENTS_SERVICES_PSI_MEMORY_H */

Diff for: include/mysql/components/services/psi_memory_bits.h

+12
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ typedef PSI_memory_key (*memory_realloc_v1_t)(PSI_memory_key key,
111111
typedef PSI_memory_key (*memory_claim_v1_t)(PSI_memory_key key, size_t size,
112112
struct PSI_thread **owner);
113113

114+
/**
115+
Instrument memory claim.
116+
@param key the memory instrument key
117+
@param size the size of memory allocated
118+
@param[in, out] owner the memory owner
119+
@param claim True to claim, false to unclaim
120+
@return the effective memory instrument key
121+
*/
122+
typedef PSI_memory_key (*memory_claim_v2_t)(PSI_memory_key key, size_t size,
123+
struct PSI_thread **owner,
124+
bool claim);
125+
114126
/**
115127
Instrument memory free.
116128
@param key the memory instrument key

Diff for: include/mysql/components/services/psi_memory_service.h

+17-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,30 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2626
#include <mysql/components/service.h>
2727
#include <mysql/components/services/psi_memory_bits.h>
2828

29-
BEGIN_SERVICE_DEFINITION(psi_memory_v1)
29+
/*
30+
Version 1.
31+
Introduced in MySQL 8.0.3
32+
Abandoned in MySQL 8.0.22
33+
Status: Removed, use version 2 instead.
34+
*/
35+
36+
/*
37+
Version 2.
38+
Introduced in MySQL 8.0.22
39+
Status: active
40+
*/
41+
42+
BEGIN_SERVICE_DEFINITION(psi_memory_v2)
3043
/** @sa register_memory_v1_t. */
3144
register_memory_v1_t register_memory;
3245
/** @sa memory_alloc_v1_t. */
3346
memory_alloc_v1_t memory_alloc;
3447
/** @sa memory_realloc_v1_t. */
3548
memory_realloc_v1_t memory_realloc;
36-
/** @sa memory_claim_v1_t. */
37-
memory_claim_v1_t memory_claim;
49+
/** @sa memory_claim_v2_t. */
50+
memory_claim_v2_t memory_claim;
3851
/** @sa memory_free_v1_t. */
3952
memory_free_v1_t memory_free;
40-
END_SERVICE_DEFINITION(psi_memory_v1)
53+
END_SERVICE_DEFINITION(psi_memory_v2)
4154

4255
#endif /* COMPONENTS_SERVICES_PSI_MEMORY_SERVICE_H */

Diff for: include/mysql/psi/psi_abi_memory_v1.h.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
struct PSI_thread **owner);
2323
typedef PSI_memory_key (*memory_claim_v1_t)(PSI_memory_key key, size_t size,
2424
struct PSI_thread **owner);
25+
typedef PSI_memory_key (*memory_claim_v2_t)(PSI_memory_key key, size_t size,
26+
struct PSI_thread **owner,
27+
bool claim);
2528
typedef void (*memory_free_v1_t)(PSI_memory_key key, size_t size,
2629
struct PSI_thread *owner);
2730
typedef struct PSI_memory_info_v1 PSI_memory_info;
@@ -31,12 +34,12 @@
3134
void *(*get_interface)(int version);
3235
};
3336
typedef struct PSI_memory_bootstrap PSI_memory_bootstrap;
34-
struct PSI_memory_service_v1 {
37+
struct PSI_memory_service_v2 {
3538
register_memory_v1_t register_memory;
3639
memory_alloc_v1_t memory_alloc;
3740
memory_realloc_v1_t memory_realloc;
38-
memory_claim_v1_t memory_claim;
41+
memory_claim_v2_t memory_claim;
3942
memory_free_v1_t memory_free;
4043
};
41-
typedef struct PSI_memory_service_v1 PSI_memory_service_t;
44+
typedef struct PSI_memory_service_v2 PSI_memory_service_t;
4245
extern PSI_memory_service_t *psi_memory_service;

Diff for: include/mysql/psi/psi_memory.h

+16-9
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,23 @@ typedef unsigned int PSI_memory_key;
5858
/**
5959
@def PSI_MEMORY_VERSION_1
6060
Performance Schema Memory Interface number for version 1.
61-
This version is supported.
61+
This version is abandoned.
6262
*/
6363
#define PSI_MEMORY_VERSION_1 1
6464

65+
/**
66+
@def PSI_MEMORY_VERSION_2
67+
Performance Schema Memory Interface number for version 2.
68+
This version is supported.
69+
*/
70+
#define PSI_MEMORY_VERSION_2 2
71+
6572
/**
6673
@def PSI_CURRENT_MEMORY_VERSION
6774
Performance Schema Memory Interface number for the most recent version.
68-
The most current version is @c PSI_MEMORY_VERSION_1
75+
The most current version is @c PSI_MEMORY_VERSION_2
6976
*/
70-
#define PSI_CURRENT_MEMORY_VERSION 1
77+
#define PSI_CURRENT_MEMORY_VERSION 2
7178

7279
struct PSI_thread;
7380

@@ -88,23 +95,23 @@ typedef struct PSI_memory_bootstrap PSI_memory_bootstrap;
8895
#ifdef HAVE_PSI_MEMORY_INTERFACE
8996

9097
/**
91-
Performance Schema Memory Interface, version 1.
92-
@since PSI_MEMORY_VERSION_1
98+
Performance Schema Memory Interface, version 2.
99+
@since PSI_MEMORY_VERSION_2
93100
*/
94-
struct PSI_memory_service_v1 {
101+
struct PSI_memory_service_v2 {
95102
/** @sa register_memory_v1_t. */
96103
register_memory_v1_t register_memory;
97104
/** @sa memory_alloc_v1_t. */
98105
memory_alloc_v1_t memory_alloc;
99106
/** @sa memory_realloc_v1_t. */
100107
memory_realloc_v1_t memory_realloc;
101-
/** @sa memory_claim_v1_t. */
102-
memory_claim_v1_t memory_claim;
108+
/** @sa memory_claim_v2_t. */
109+
memory_claim_v2_t memory_claim;
103110
/** @sa memory_free_v1_t. */
104111
memory_free_v1_t memory_free;
105112
};
106113

107-
typedef struct PSI_memory_service_v1 PSI_memory_service_t;
114+
typedef struct PSI_memory_service_v2 PSI_memory_service_t;
108115

109116
extern MYSQL_PLUGIN_IMPORT PSI_memory_service_t *psi_memory_service;
110117

Diff for: include/mysql/service_mysql_alloc.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -40,7 +40,7 @@ typedef int myf_t;
4040
typedef void *(*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags);
4141
typedef void *(*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size,
4242
myf_t flags);
43-
typedef void (*mysql_claim_t)(const void *ptr);
43+
typedef void (*mysql_claim_t)(const void *ptr, bool claim);
4444
typedef void (*mysql_free_t)(void *ptr);
4545
typedef void *(*my_memdup_t)(PSI_memory_key key, const void *from,
4646
size_t length, myf_t flags);
@@ -117,7 +117,7 @@ extern "C" struct mysql_malloc_service_st *mysql_malloc_service;
117117
extern void *my_malloc(PSI_memory_key key, size_t size, myf_t flags);
118118
extern void *my_realloc(PSI_memory_key key, void *ptr, size_t size,
119119
myf_t flags);
120-
extern void my_claim(const void *ptr);
120+
extern void my_claim(const void *ptr, bool claim);
121121
extern void my_free(void *ptr);
122122
extern void *my_memdup(PSI_memory_key key, const void *from, size_t length,
123123
myf_t flags);

Diff for: include/mysql/services.h.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,17 @@
276276
struct PSI_thread **owner);
277277
typedef PSI_memory_key (*memory_claim_v1_t)(PSI_memory_key key, size_t size,
278278
struct PSI_thread **owner);
279+
typedef PSI_memory_key (*memory_claim_v2_t)(PSI_memory_key key, size_t size,
280+
struct PSI_thread **owner,
281+
bool claim);
279282
typedef void (*memory_free_v1_t)(PSI_memory_key key, size_t size,
280283
struct PSI_thread *owner);
281284
typedef struct PSI_memory_info_v1 PSI_memory_info;
282285
typedef int myf_t;
283286
typedef void *(*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags);
284287
typedef void *(*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size,
285288
myf_t flags);
286-
typedef void (*mysql_claim_t)(const void *ptr);
289+
typedef void (*mysql_claim_t)(const void *ptr, bool claim);
287290
typedef void (*mysql_free_t)(void *ptr);
288291
typedef void *(*my_memdup_t)(PSI_memory_key key, const void *from,
289292
size_t length, myf_t flags);
@@ -303,7 +306,7 @@
303306
extern void *my_malloc(PSI_memory_key key, size_t size, myf_t flags);
304307
extern void *my_realloc(PSI_memory_key key, void *ptr, size_t size,
305308
myf_t flags);
306-
extern void my_claim(const void *ptr);
309+
extern void my_claim(const void *ptr, bool claim);
307310
extern void my_free(void *ptr);
308311
extern void *my_memdup(PSI_memory_key key, const void *from, size_t length,
309312
myf_t flags);

Diff for: include/mysql_com.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ bool my_net_init(struct NET *net, MYSQL_VIO vio);
10231023
void my_net_local_init(struct NET *net);
10241024
void net_end(struct NET *net);
10251025
void net_clear(struct NET *net, bool check_buffer);
1026-
void net_claim_memory_ownership(struct NET *net);
1026+
void net_claim_memory_ownership(struct NET *net, bool claim);
10271027
bool net_realloc(struct NET *net, size_t length);
10281028
bool net_flush(struct NET *net);
10291029
bool my_net_write(struct NET *net, const unsigned char *packet, size_t len);

Diff for: include/pfs_memory_provider.h

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -42,18 +42,21 @@
4242

4343
struct PSI_thread;
4444

45-
#define PSI_MEMORY_CALL(M) pfs_##M##_v1
45+
#define PSI_MEMORY_CALL(M) pfs_##M##_vc
4646

47-
void pfs_register_memory_v1(const char *category,
47+
void pfs_register_memory_vc(const char *category,
4848
struct PSI_memory_info_v1 *info, int count);
4949

50-
PSI_memory_key pfs_memory_alloc_v1(PSI_memory_key key, size_t size,
50+
PSI_memory_key pfs_memory_alloc_vc(PSI_memory_key key, size_t size,
5151
PSI_thread **owner);
5252

53-
PSI_memory_key pfs_memory_realloc_v1(PSI_memory_key key, size_t old_size,
53+
PSI_memory_key pfs_memory_realloc_vc(PSI_memory_key key, size_t old_size,
5454
size_t new_size, PSI_thread **owner);
5555

56-
void pfs_memory_free_v1(PSI_memory_key key, size_t size, PSI_thread *owner);
56+
PSI_memory_key pfs_memory_claim_vc(PSI_memory_key key, size_t size,
57+
PSI_thread **owner, bool claim);
58+
59+
void pfs_memory_free_vc(PSI_memory_key key, size_t size, PSI_thread *owner);
5760

5861
#endif /* WITH_LOCK_ORDER */
5962
#endif /* MYSQL_DYNAMIC_PLUGIN */

Diff for: include/sql_string.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ class String {
366366
m_ptr[m_length] = '\0';
367367
}
368368

369-
void mem_claim() {
369+
void mem_claim(bool claim) {
370370
if (m_is_alloced) {
371-
my_claim(m_ptr);
371+
my_claim(m_ptr, claim);
372372
}
373373
}
374374

Diff for: mysys/my_alloc.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
22
This program is free software; you can redistribute it and/or modify
33
it under the terms of the GNU General Public License, version 2.0,
44
as published by the Free Software Foundation.
@@ -183,12 +183,12 @@ void MEM_ROOT::FreeBlocks(Block *start) {
183183
}
184184
}
185185

186-
void MEM_ROOT::Claim() {
186+
void MEM_ROOT::Claim(bool claim) {
187187
DBUG_TRACE;
188188
DBUG_PRINT("enter", ("root: %p", this));
189189

190190
for (Block *block = m_current_block; block != nullptr; block = block->prev) {
191-
my_claim(block);
191+
my_claim(block, claim);
192192
}
193193
}
194194

Diff for: mysys/my_malloc.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -128,15 +128,15 @@ void *my_realloc(PSI_memory_key key, void *ptr, size_t size, myf flags) {
128128
return nullptr;
129129
}
130130

131-
void my_claim(const void *ptr) {
131+
void my_claim(const void *ptr, bool claim) {
132132
my_memory_header *mh;
133133

134134
if (ptr == nullptr) return;
135135

136136
mh = USER_TO_HEADER(const_cast<void *>(ptr));
137137
DBUG_ASSERT(mh->m_magic == MAGIC);
138138
mh->m_key =
139-
PSI_MEMORY_CALL(memory_claim)(mh->m_key, mh->m_size, &mh->m_owner);
139+
PSI_MEMORY_CALL(memory_claim)(mh->m_key, mh->m_size, &mh->m_owner, claim);
140140
}
141141

142142
void my_free(void *ptr) {
@@ -167,7 +167,8 @@ void *my_realloc(PSI_memory_key key MY_ATTRIBUTE((unused)), void *ptr,
167167
return my_raw_realloc(ptr, size, flags);
168168
}
169169

170-
void my_claim(const void *ptr MY_ATTRIBUTE((unused))) { /* Empty */
170+
void my_claim(const void *ptr MY_ATTRIBUTE((unused)),
171+
bool claim MY_ATTRIBUTE((unused))) { /* Empty */
171172
}
172173

173174
void my_free(void *ptr) { my_raw_free(ptr); }

Diff for: mysys/psi_noop.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ static PSI_memory_key memory_realloc_noop(PSI_memory_key, size_t, size_t,
896896
}
897897

898898
static PSI_memory_key memory_claim_noop(PSI_memory_key, size_t,
899-
struct PSI_thread **owner) {
899+
struct PSI_thread **owner, bool) {
900900
*owner = nullptr;
901901
return PSI_NOT_INSTRUMENTED;
902902
}

Diff for: sql-common/net_serv.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ void net_end(NET *net) {
197197
net->buff = nullptr;
198198
}
199199

200-
void net_claim_memory_ownership(NET *net) { my_claim(net->buff); }
200+
void net_claim_memory_ownership(NET *net, bool claim) {
201+
my_claim(net->buff, claim);
202+
}
201203

202204
/** Realloc the packet buffer. */
203205

Diff for: sql/debug_sync.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ void debug_sync_init_thread(THD *thd) {
671671
}
672672
}
673673

674-
void debug_sync_claim_memory_ownership(THD *thd) {
674+
void debug_sync_claim_memory_ownership(THD *thd, bool claim) {
675675
DBUG_TRACE;
676676
DBUG_ASSERT(thd);
677677

@@ -682,14 +682,14 @@ void debug_sync_claim_memory_ownership(THD *thd) {
682682
st_debug_sync_action *action = ds_control->ds_action;
683683
st_debug_sync_action *action_end = action + ds_control->ds_allocated;
684684
for (; action < action_end; action++) {
685-
action->signal.mem_claim();
686-
action->wait_for.mem_claim();
687-
action->sync_point.mem_claim();
685+
action->signal.mem_claim(claim);
686+
action->wait_for.mem_claim(claim);
687+
action->sync_point.mem_claim(claim);
688688
}
689-
my_claim(ds_control->ds_action);
689+
my_claim(ds_control->ds_action, claim);
690690
}
691691

692-
my_claim(ds_control);
692+
my_claim(ds_control, claim);
693693
}
694694
}
695695

0 commit comments

Comments
 (0)