Skip to content

Commit 69b75d3

Browse files
author
Tatiana Azundris Nuernberg
committed
Bug#30569003: 5.7 REPLICATION BREAKAGE WITH SYNTAX ERROR WITH GRANT MANAGEMENT
The server creates a rewritten query with sensitive information such as passwords obfuscated. Various functions in sql_user.cc and sql_authorization.cc caused a second rewrite to happen (this time to include hashed passwords for use in the binlog). This freed and reassigned the rewritten_query on the THD. This could lead to problems when SHOW PROCESSLIST in another thread had already obtained a pointer to the old value. Vice versa, re-allocation could also happen in SHOW PROCESSLIST's c_ptr_safe() while the user/auth code was assembling a rewritten query. This was possible because of the aforementioned functions, only SHOW PROCESSLIST obtained a lock. This patch fixes the immediate problem by making rewritten_query on the THD private and adding a (const) getter and a setter (that acquire LOCK_thd_query) to make the interface clearer and safer to prevent similar issues in the future. This also means that while a rewritten query may be assembled in several steps, it is now only updated on the THD once complete. Approved by: Praveenkumar Hulakund <praveenkumar.hulakund@oracle.com>
1 parent b747782 commit 69b75d3

14 files changed

+428
-252
lines changed

mysql-test/suite/perfschema/r/nesting.result

+132-123
Original file line numberDiff line numberDiff line change
@@ -120,132 +120,141 @@ and (end_event_id <= @marker_end)
120120
) all_events
121121
order by relative_event_id asc;
122122
relative_event_id relative_end_event_id event_name comment nesting_event_type relative_nesting_event_id
123-
0 17 statement/sql/select select "MARKER_BEGIN" as marker NULL NULL
124-
1 5 stage/sql/starting (stage) STATEMENT 0
123+
0 18 statement/sql/select select "MARKER_BEGIN" as marker NULL NULL
124+
1 6 stage/sql/starting (stage) STATEMENT 0
125125
2 2 wait/io/socket/sql/client_connection recv STAGE 1
126126
3 3 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 1
127127
4 4 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 1
128-
5 5 wait/io/file/sql/query_log write STAGE 1
129-
6 6 stage/sql/checking permissions (stage) STATEMENT 0
130-
7 7 stage/sql/Opening tables (stage) STATEMENT 0
131-
8 8 stage/sql/init (stage) STATEMENT 0
132-
9 9 stage/sql/optimizing (stage) STATEMENT 0
133-
10 10 stage/sql/executing (stage) STATEMENT 0
134-
11 11 stage/sql/end (stage) STATEMENT 0
135-
12 12 stage/sql/query end (stage) STATEMENT 0
136-
13 13 stage/sql/closing tables (stage) STATEMENT 0
137-
14 15 stage/sql/freeing items (stage) STATEMENT 0
138-
15 15 wait/io/socket/sql/client_connection send STAGE 14
139-
16 17 stage/sql/cleaning up (stage) STATEMENT 0
140-
17 17 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 16
141-
18 18 idle idle NULL NULL
142-
19 36 statement/sql/select select "This is simple statement one" as payload NULL NULL
143-
20 24 stage/sql/starting (stage) STATEMENT 19
144-
21 21 wait/io/socket/sql/client_connection recv STAGE 20
145-
22 22 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 20
146-
23 23 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 20
147-
24 24 wait/io/file/sql/query_log write STAGE 20
148-
25 25 stage/sql/checking permissions (stage) STATEMENT 19
149-
26 26 stage/sql/Opening tables (stage) STATEMENT 19
150-
27 27 stage/sql/init (stage) STATEMENT 19
151-
28 28 stage/sql/optimizing (stage) STATEMENT 19
152-
29 29 stage/sql/executing (stage) STATEMENT 19
153-
30 30 stage/sql/end (stage) STATEMENT 19
154-
31 31 stage/sql/query end (stage) STATEMENT 19
155-
32 32 stage/sql/closing tables (stage) STATEMENT 19
156-
33 34 stage/sql/freeing items (stage) STATEMENT 19
157-
34 34 wait/io/socket/sql/client_connection send STAGE 33
158-
35 36 stage/sql/cleaning up (stage) STATEMENT 19
159-
36 36 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 35
160-
37 37 idle idle NULL NULL
161-
38 55 statement/sql/select select "This is simple statement two" as payload NULL NULL
162-
39 43 stage/sql/starting (stage) STATEMENT 38
163-
40 40 wait/io/socket/sql/client_connection recv STAGE 39
164-
41 41 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 39
165-
42 42 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 39
166-
43 43 wait/io/file/sql/query_log write STAGE 39
167-
44 44 stage/sql/checking permissions (stage) STATEMENT 38
168-
45 45 stage/sql/Opening tables (stage) STATEMENT 38
169-
46 46 stage/sql/init (stage) STATEMENT 38
170-
47 47 stage/sql/optimizing (stage) STATEMENT 38
171-
48 48 stage/sql/executing (stage) STATEMENT 38
172-
49 49 stage/sql/end (stage) STATEMENT 38
173-
50 50 stage/sql/query end (stage) STATEMENT 38
174-
51 51 stage/sql/closing tables (stage) STATEMENT 38
175-
52 53 stage/sql/freeing items (stage) STATEMENT 38
176-
53 53 wait/io/socket/sql/client_connection send STAGE 52
177-
54 55 stage/sql/cleaning up (stage) STATEMENT 38
178-
55 55 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 54
179-
56 56 idle idle NULL NULL
180-
57 73 statement/sql/select select "This is the first part of a multi query" as payload;
128+
5 5 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 1
129+
6 6 wait/io/file/sql/query_log write STAGE 1
130+
7 7 stage/sql/checking permissions (stage) STATEMENT 0
131+
8 8 stage/sql/Opening tables (stage) STATEMENT 0
132+
9 9 stage/sql/init (stage) STATEMENT 0
133+
10 10 stage/sql/optimizing (stage) STATEMENT 0
134+
11 11 stage/sql/executing (stage) STATEMENT 0
135+
12 12 stage/sql/end (stage) STATEMENT 0
136+
13 13 stage/sql/query end (stage) STATEMENT 0
137+
14 14 stage/sql/closing tables (stage) STATEMENT 0
138+
15 16 stage/sql/freeing items (stage) STATEMENT 0
139+
16 16 wait/io/socket/sql/client_connection send STAGE 15
140+
17 18 stage/sql/cleaning up (stage) STATEMENT 0
141+
18 18 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 17
142+
19 19 wait/synch/mutex/sql/THD::LOCK_thd_query lock STATEMENT 0
143+
20 20 idle idle NULL NULL
144+
21 39 statement/sql/select select "This is simple statement one" as payload NULL NULL
145+
22 27 stage/sql/starting (stage) STATEMENT 21
146+
23 23 wait/io/socket/sql/client_connection recv STAGE 22
147+
24 24 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 22
148+
25 25 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 22
149+
26 26 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 22
150+
27 27 wait/io/file/sql/query_log write STAGE 22
151+
28 28 stage/sql/checking permissions (stage) STATEMENT 21
152+
29 29 stage/sql/Opening tables (stage) STATEMENT 21
153+
30 30 stage/sql/init (stage) STATEMENT 21
154+
31 31 stage/sql/optimizing (stage) STATEMENT 21
155+
32 32 stage/sql/executing (stage) STATEMENT 21
156+
33 33 stage/sql/end (stage) STATEMENT 21
157+
34 34 stage/sql/query end (stage) STATEMENT 21
158+
35 35 stage/sql/closing tables (stage) STATEMENT 21
159+
36 37 stage/sql/freeing items (stage) STATEMENT 21
160+
37 37 wait/io/socket/sql/client_connection send STAGE 36
161+
38 39 stage/sql/cleaning up (stage) STATEMENT 21
162+
39 39 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 38
163+
40 40 wait/synch/mutex/sql/THD::LOCK_thd_query lock STATEMENT 21
164+
41 41 idle idle NULL NULL
165+
42 60 statement/sql/select select "This is simple statement two" as payload NULL NULL
166+
43 48 stage/sql/starting (stage) STATEMENT 42
167+
44 44 wait/io/socket/sql/client_connection recv STAGE 43
168+
45 45 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 43
169+
46 46 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 43
170+
47 47 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 43
171+
48 48 wait/io/file/sql/query_log write STAGE 43
172+
49 49 stage/sql/checking permissions (stage) STATEMENT 42
173+
50 50 stage/sql/Opening tables (stage) STATEMENT 42
174+
51 51 stage/sql/init (stage) STATEMENT 42
175+
52 52 stage/sql/optimizing (stage) STATEMENT 42
176+
53 53 stage/sql/executing (stage) STATEMENT 42
177+
54 54 stage/sql/end (stage) STATEMENT 42
178+
55 55 stage/sql/query end (stage) STATEMENT 42
179+
56 56 stage/sql/closing tables (stage) STATEMENT 42
180+
57 58 stage/sql/freeing items (stage) STATEMENT 42
181+
58 58 wait/io/socket/sql/client_connection send STAGE 57
182+
59 60 stage/sql/cleaning up (stage) STATEMENT 42
183+
60 60 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 59
184+
61 61 wait/synch/mutex/sql/THD::LOCK_thd_query lock STATEMENT 42
185+
62 62 idle idle NULL NULL
186+
63 80 statement/sql/select select "This is the first part of a multi query" as payload;
181187
select "And this is the second part of a multi query" as payload;
182188
select "With a third part to make things complete" as payload NULL NULL
183-
58 63 stage/sql/starting (stage) STATEMENT 57
184-
59 59 wait/io/socket/sql/client_connection recv STAGE 58
185-
60 60 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 58
186-
61 61 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 58
187-
62 62 wait/io/file/sql/query_log write STAGE 58
188-
63 63 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 58
189-
64 64 stage/sql/checking permissions (stage) STATEMENT 57
190-
65 65 stage/sql/Opening tables (stage) STATEMENT 57
191-
66 66 stage/sql/init (stage) STATEMENT 57
192-
67 67 stage/sql/optimizing (stage) STATEMENT 57
193-
68 68 stage/sql/executing (stage) STATEMENT 57
194-
69 69 stage/sql/end (stage) STATEMENT 57
195-
70 70 stage/sql/query end (stage) STATEMENT 57
196-
71 71 stage/sql/closing tables (stage) STATEMENT 57
197-
72 73 stage/sql/freeing items (stage) STATEMENT 57
198-
73 73 wait/io/socket/sql/client_connection send STAGE 72
199-
74 89 statement/sql/select select "And this is the second part of a multi query" as payload;
189+
64 70 stage/sql/starting (stage) STATEMENT 63
190+
65 65 wait/io/socket/sql/client_connection recv STAGE 64
191+
66 66 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 64
192+
67 67 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 64
193+
68 68 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 64
194+
69 69 wait/io/file/sql/query_log write STAGE 64
195+
70 70 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 64
196+
71 71 stage/sql/checking permissions (stage) STATEMENT 63
197+
72 72 stage/sql/Opening tables (stage) STATEMENT 63
198+
73 73 stage/sql/init (stage) STATEMENT 63
199+
74 74 stage/sql/optimizing (stage) STATEMENT 63
200+
75 75 stage/sql/executing (stage) STATEMENT 63
201+
76 76 stage/sql/end (stage) STATEMENT 63
202+
77 77 stage/sql/query end (stage) STATEMENT 63
203+
78 78 stage/sql/closing tables (stage) STATEMENT 63
204+
79 80 stage/sql/freeing items (stage) STATEMENT 63
205+
80 80 wait/io/socket/sql/client_connection send STAGE 79
206+
81 96 statement/sql/select select "And this is the second part of a multi query" as payload;
200207
select "With a third part to make things complete" as payload NULL NULL
201-
75 79 stage/sql/starting (stage) STATEMENT 74
202-
76 76 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 75
203-
77 77 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 75
204-
78 78 wait/io/file/sql/query_log write STAGE 75
205-
79 79 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 75
206-
80 80 stage/sql/checking permissions (stage) STATEMENT 74
207-
81 81 stage/sql/Opening tables (stage) STATEMENT 74
208-
82 82 stage/sql/init (stage) STATEMENT 74
209-
83 83 stage/sql/optimizing (stage) STATEMENT 74
210-
84 84 stage/sql/executing (stage) STATEMENT 74
211-
85 85 stage/sql/end (stage) STATEMENT 74
212-
86 86 stage/sql/query end (stage) STATEMENT 74
213-
87 87 stage/sql/closing tables (stage) STATEMENT 74
214-
88 89 stage/sql/freeing items (stage) STATEMENT 74
215-
89 89 wait/io/socket/sql/client_connection send STAGE 88
216-
90 106 statement/sql/select select "With a third part to make things complete" as payload NULL NULL
217-
91 94 stage/sql/starting (stage) STATEMENT 90
218-
92 92 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 91
219-
93 93 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 91
220-
94 94 wait/io/file/sql/query_log write STAGE 91
221-
95 95 stage/sql/checking permissions (stage) STATEMENT 90
222-
96 96 stage/sql/Opening tables (stage) STATEMENT 90
223-
97 97 stage/sql/init (stage) STATEMENT 90
224-
98 98 stage/sql/optimizing (stage) STATEMENT 90
225-
99 99 stage/sql/executing (stage) STATEMENT 90
226-
100 100 stage/sql/end (stage) STATEMENT 90
227-
101 101 stage/sql/query end (stage) STATEMENT 90
228-
102 102 stage/sql/closing tables (stage) STATEMENT 90
229-
103 104 stage/sql/freeing items (stage) STATEMENT 90
230-
104 104 wait/io/socket/sql/client_connection send STAGE 103
231-
105 106 stage/sql/cleaning up (stage) STATEMENT 90
232-
106 106 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 105
233-
107 107 idle idle NULL NULL
234-
108 125 statement/sql/select select "MARKER_END" as marker NULL NULL
235-
109 113 stage/sql/starting (stage) STATEMENT 108
236-
110 110 wait/io/socket/sql/client_connection recv STAGE 109
237-
111 111 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 109
238-
112 112 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 109
239-
113 113 wait/io/file/sql/query_log write STAGE 109
240-
114 114 stage/sql/checking permissions (stage) STATEMENT 108
241-
115 115 stage/sql/Opening tables (stage) STATEMENT 108
242-
116 116 stage/sql/init (stage) STATEMENT 108
243-
117 117 stage/sql/optimizing (stage) STATEMENT 108
244-
118 118 stage/sql/executing (stage) STATEMENT 108
245-
119 119 stage/sql/end (stage) STATEMENT 108
246-
120 120 stage/sql/query end (stage) STATEMENT 108
247-
121 121 stage/sql/closing tables (stage) STATEMENT 108
248-
122 123 stage/sql/freeing items (stage) STATEMENT 108
249-
123 123 wait/io/socket/sql/client_connection send STAGE 122
250-
124 125 stage/sql/cleaning up (stage) STATEMENT 108
251-
125 125 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 124
208+
82 86 stage/sql/starting (stage) STATEMENT 81
209+
83 83 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 82
210+
84 84 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 82
211+
85 85 wait/io/file/sql/query_log write STAGE 82
212+
86 86 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 82
213+
87 87 stage/sql/checking permissions (stage) STATEMENT 81
214+
88 88 stage/sql/Opening tables (stage) STATEMENT 81
215+
89 89 stage/sql/init (stage) STATEMENT 81
216+
90 90 stage/sql/optimizing (stage) STATEMENT 81
217+
91 91 stage/sql/executing (stage) STATEMENT 81
218+
92 92 stage/sql/end (stage) STATEMENT 81
219+
93 93 stage/sql/query end (stage) STATEMENT 81
220+
94 94 stage/sql/closing tables (stage) STATEMENT 81
221+
95 96 stage/sql/freeing items (stage) STATEMENT 81
222+
96 96 wait/io/socket/sql/client_connection send STAGE 95
223+
97 113 statement/sql/select select "With a third part to make things complete" as payload NULL NULL
224+
98 101 stage/sql/starting (stage) STATEMENT 97
225+
99 99 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 98
226+
100 100 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 98
227+
101 101 wait/io/file/sql/query_log write STAGE 98
228+
102 102 stage/sql/checking permissions (stage) STATEMENT 97
229+
103 103 stage/sql/Opening tables (stage) STATEMENT 97
230+
104 104 stage/sql/init (stage) STATEMENT 97
231+
105 105 stage/sql/optimizing (stage) STATEMENT 97
232+
106 106 stage/sql/executing (stage) STATEMENT 97
233+
107 107 stage/sql/end (stage) STATEMENT 97
234+
108 108 stage/sql/query end (stage) STATEMENT 97
235+
109 109 stage/sql/closing tables (stage) STATEMENT 97
236+
110 111 stage/sql/freeing items (stage) STATEMENT 97
237+
111 111 wait/io/socket/sql/client_connection send STAGE 110
238+
112 113 stage/sql/cleaning up (stage) STATEMENT 97
239+
113 113 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 112
240+
114 114 wait/synch/mutex/sql/THD::LOCK_thd_query lock STATEMENT 97
241+
115 115 idle idle NULL NULL
242+
116 134 statement/sql/select select "MARKER_END" as marker NULL NULL
243+
117 122 stage/sql/starting (stage) STATEMENT 116
244+
118 118 wait/io/socket/sql/client_connection recv STAGE 117
245+
119 119 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 117
246+
120 120 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 117
247+
121 121 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 117
248+
122 122 wait/io/file/sql/query_log write STAGE 117
249+
123 123 stage/sql/checking permissions (stage) STATEMENT 116
250+
124 124 stage/sql/Opening tables (stage) STATEMENT 116
251+
125 125 stage/sql/init (stage) STATEMENT 116
252+
126 126 stage/sql/optimizing (stage) STATEMENT 116
253+
127 127 stage/sql/executing (stage) STATEMENT 116
254+
128 128 stage/sql/end (stage) STATEMENT 116
255+
129 129 stage/sql/query end (stage) STATEMENT 116
256+
130 130 stage/sql/closing tables (stage) STATEMENT 116
257+
131 132 stage/sql/freeing items (stage) STATEMENT 116
258+
132 132 wait/io/socket/sql/client_connection send STAGE 131
259+
133 134 stage/sql/cleaning up (stage) STATEMENT 116
260+
134 134 wait/synch/mutex/sql/THD::LOCK_thd_query lock STAGE 133

sql/auth/sql_authorization.cc

+40-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2019, 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,
@@ -1470,17 +1470,21 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
14701470
}
14711471
else
14721472
{
1473-
if (!revoke_grant)
1474-
{
1475-
String *rlb= &thd->rewritten_query;
1476-
rlb->mem_free();
1477-
mysql_rewrite_grant(thd, rlb);
1473+
/*
1474+
Rewrite (table) GRANT statements to use password hashes
1475+
instead of <secret> style obfuscation so it can be used
1476+
in binlog.
1477+
*/
1478+
if (!revoke_grant) {
1479+
String rlb;
1480+
mysql_rewrite_grant(thd, &rlb);
1481+
thd->swap_rewritten_query(rlb);
14781482
}
1479-
if (thd->rewritten_query.length())
1483+
1484+
if (thd->rewritten_query().length() > 0)
14801485
result= result |
1481-
write_bin_log(thd, FALSE,
1482-
thd->rewritten_query.c_ptr_safe(),
1483-
thd->rewritten_query.length(),
1486+
write_bin_log(thd, FALSE, thd->rewritten_query().ptr(),
1487+
thd->rewritten_query().length(),
14841488
transactional_tables);
14851489
else
14861490
result= result |
@@ -1727,27 +1731,31 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
17271731
}
17281732
else
17291733
{
1730-
if (!revoke_grant)
1731-
{
1732-
String *rlb= &thd->rewritten_query;
1733-
rlb->mem_free();
1734-
mysql_rewrite_grant(thd, rlb);
1734+
/*
1735+
Rewrite (routine) GRANT statements to use password hashes
1736+
instead of <secret> style obfuscation so it can be used
1737+
in binlog.
1738+
*/
1739+
if (!revoke_grant) {
1740+
String rlb;
1741+
mysql_rewrite_grant(thd, &rlb);
1742+
thd->swap_rewritten_query(rlb);
17351743
}
1744+
17361745
/*
17371746
For performance reasons, we don't rewrite the query if we don't have to.
17381747
If that was the case, write the original query.
17391748
*/
1740-
if (!thd->rewritten_query.length())
1749+
if (thd->rewritten_query().length() == 0)
17411750
{
17421751
if (write_bin_log(thd, false, thd->query().str, thd->query().length,
17431752
transactional_tables))
17441753
result= TRUE;
17451754
}
17461755
else
17471756
{
1748-
if (write_bin_log(thd, false,
1749-
thd->rewritten_query.c_ptr_safe(),
1750-
thd->rewritten_query.length(),
1757+
if (write_bin_log(thd, false, thd->rewritten_query().ptr(),
1758+
thd->rewritten_query().length(),
17511759
transactional_tables))
17521760
result= TRUE;
17531761
}
@@ -1993,18 +2001,22 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
19932001
}
19942002
else
19952003
{
1996-
if (!revoke_grant)
1997-
{
1998-
String *rlb= &thd->rewritten_query;
1999-
rlb->mem_free();
2000-
mysql_rewrite_grant(thd, rlb);
2004+
/*
2005+
Rewrite GRANT statements to use password hashes instead of
2006+
<secret> style obfuscation so it can be used in binlog.
2007+
*/
2008+
if (!revoke_grant) {
2009+
String rlb;
2010+
mysql_rewrite_grant(thd, &rlb);
2011+
thd->swap_rewritten_query(rlb);
20012012
}
2002-
if (thd->rewritten_query.length())
2013+
2014+
if (thd->rewritten_query().length() > 0) {
20032015
result= result |
2004-
write_bin_log(thd, FALSE,
2005-
thd->rewritten_query.c_ptr_safe(),
2006-
thd->rewritten_query.length(),
2016+
write_bin_log(thd, FALSE, thd->rewritten_query().ptr(),
2017+
thd->rewritten_query().length(),
20072018
transactional_tables);
2019+
}
20082020
else
20092021
result= result |
20102022
write_bin_log(thd, FALSE, thd->query().str, thd->query().length,

0 commit comments

Comments
 (0)