Skip to content

Commit c640c63

Browse files
committed
Revert "Bug#30654405: PORT FIX FOR BUG#30569003 / REFACTORING OF REWRITTEN_QUERY PROCESSING TO 8.X"
Approved-by: Jon Olav Hauglid <jon.hauglid@oracle.com>
1 parent bb9c700 commit c640c63

18 files changed

+455
-606
lines changed

include/sql_string.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SQL_STRING_INCLUDED
22
#define SQL_STRING_INCLUDED
33

4-
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
4+
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License, version 2.0,
@@ -446,9 +446,9 @@ class String {
446446
}
447447
/**
448448
Takeover the buffer owned by another string.
449-
"this" becomes the owner of the buffer and
449+
"this" becames the owner of the buffer and
450450
is further responsible to free it.
451-
The string "s" is detached from the buffer (cleared).
451+
The string "s" is detouched from the buffer (cleared).
452452
453453
@param s - a String object to steal buffer from.
454454
*/

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

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

sql/auth/sql_user.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2019, 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.
@@ -343,8 +343,9 @@ bool mysql_show_create_user(THD *thd, LEX_USER *user_name,
343343
{
344344
Show_user_params show_user_params(
345345
hide_password_hash, thd->variables.print_identified_with_as_hex);
346-
mysql_rewrite_acl_query(thd, sql_text, Consumer_type::STDOUT,
347-
&show_user_params, false);
346+
mysql_rewrite_acl_query(thd, Consumer_type::STDOUT, &show_user_params,
347+
false);
348+
sql_text.takeover(thd->rewritten_query);
348349
}
349350

350351
/* send the result row to client */

sql/auth/sql_user_table.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2020, 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,
@@ -560,8 +560,9 @@ Acl_change_notification::Acl_change_notification(
560560
THD *thd, enum_sql_command op, const List<LEX_USER> *users,
561561
const List<LEX_CSTRING> *dynamic_privs)
562562
: operation(op), db(thd->db().str, thd->db().length) {
563-
if (thd->rewritten_query().length()) {
564-
query.assign(thd->rewritten_query().ptr(), thd->rewritten_query().length());
563+
if (thd->rewritten_query.length()) {
564+
query.assign(thd->rewritten_query.c_ptr_safe(),
565+
thd->rewritten_query.length());
565566
} else {
566567
query.assign(thd->query().str, thd->query().length);
567568
}
@@ -703,20 +704,19 @@ bool log_and_commit_acl_ddl(THD *thd, bool transactional_tables,
703704
result = thd->is_error() || extra_error || thd->transaction_rollback_request;
704705
/* Write to binlog and textlogs only if there is no error */
705706
if (!result) {
706-
String rlb;
707-
mysql_rewrite_acl_query(thd, rlb, Consumer_type::BINLOG, rewrite_params);
707+
mysql_rewrite_acl_query(thd, Consumer_type::BINLOG, rewrite_params);
708708
if (write_to_binlog) {
709709
LEX_CSTRING query;
710710
enum_sql_command command;
711711
size_t num_extra_users = extra_users ? extra_users->size() : 0;
712712
command = thd->lex->sql_command;
713713
if (mysql_bin_log.is_open()) {
714-
query.str = thd->rewritten_query().length()
715-
? thd->rewritten_query().ptr()
714+
query.str = thd->rewritten_query.length()
715+
? thd->rewritten_query.c_ptr_safe()
716716
: thd->query().str;
717717

718-
query.length = thd->rewritten_query().length()
719-
? thd->rewritten_query().length()
718+
query.length = thd->rewritten_query.length()
719+
? thd->rewritten_query.length()
720720
: thd->query().length;
721721

722722
/* Write to binary log */
@@ -763,7 +763,7 @@ bool log_and_commit_acl_ddl(THD *thd, bool transactional_tables,
763763
Rewrite query in the thd again for the consistent logging for all consumer
764764
type TEXTLOG later on. For instance: Audit logs.
765765
*/
766-
mysql_rewrite_acl_query(thd, rlb, Consumer_type::TEXTLOG, rewrite_params);
766+
mysql_rewrite_acl_query(thd, Consumer_type::TEXTLOG, rewrite_params);
767767
}
768768

769769
if (acl_end_trans_and_close_tables(thd, result)) result = true;

sql/log.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1637,9 +1637,9 @@ void log_slow_do(THD *thd, struct System_status_var *query_start_status) {
16371637
THD_STAGE_INFO(thd, stage_logging_slow_query);
16381638
thd->status_var.long_query_count++;
16391639

1640-
if (thd->rewritten_query().length())
1641-
query_logger.slow_log_write(thd, thd->rewritten_query().ptr(),
1642-
thd->rewritten_query().length(),
1640+
if (thd->rewritten_query.length())
1641+
query_logger.slow_log_write(thd, thd->rewritten_query.c_ptr_safe(),
1642+
thd->rewritten_query.length(),
16431643
query_start_status);
16441644
else
16451645
query_logger.slow_log_write(thd, thd->query().str, thd->query().length,

sql/log_event.cc

+10-14
Original file line numberDiff line numberDiff line change
@@ -4797,10 +4797,6 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
47974797
query_start_status = thd->status_var;
47984798
}
47994799

4800-
/*
4801-
Prevent "hanging" of previous rewritten query in SHOW PROCESSLIST.
4802-
*/
4803-
thd->reset_rewritten_query();
48044800
mysql_parse(thd, &parser_state);
48054801

48064802
enum_sql_command command = thd->lex->sql_command;
@@ -4883,24 +4879,24 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
48834879
}
48844880
goto end;
48854881
}
4882+
48864883
/* If the query was not ignored, it is printed to the general log */
48874884
if (!thd->is_error() ||
48884885
thd->get_stmt_da()->mysql_errno() != ER_SLAVE_IGNORED_TABLE) {
4889-
/*
4890-
Log the rewritten query if the query was rewritten
4891-
and the option to log raw was not set.
4886+
/* log the rewritten query if the query was rewritten
4887+
and the option to log raw was not set.
48924888

4893-
There is an assumption here. We assume that query log
4894-
events can never have multi-statement queries, thus the
4895-
parsed statement is the same as the raw one.
4896-
*/
4897-
if (opt_general_log_raw || thd->rewritten_query().length() == 0)
4889+
There is an assumption here. We assume that query log
4890+
events can never have multi-statement queries, thus the
4891+
parsed statement is the same as the raw one.
4892+
*/
4893+
if (opt_general_log_raw || thd->rewritten_query.length() == 0)
48984894
query_logger.general_log_write(thd, COM_QUERY, thd->query().str,
48994895
thd->query().length);
49004896
else
49014897
query_logger.general_log_write(thd, COM_QUERY,
4902-
thd->rewritten_query().ptr(),
4903-
thd->rewritten_query().length());
4898+
thd->rewritten_query.c_ptr_safe(),
4899+
thd->rewritten_query.length());
49044900
}
49054901

49064902
compare_errors:

0 commit comments

Comments
 (0)