Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0a9633ee
Commit
0a9633ee
authored
Mar 07, 2020
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic LEX::print function that supports UPDATEs
parent
92eed38c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
sql/sql_lex.cc
sql/sql_lex.cc
+64
-0
sql/sql_lex.h
sql/sql_lex.h
+1
-0
No files found.
sql/sql_lex.cc
View file @
0a9633ee
...
@@ -3514,6 +3514,70 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
...
@@ -3514,6 +3514,70 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
}
}
/*
@brief
Print the whole statement
@param str Print into this string
@param query_type Flags describing how to print
@detail
The intent is to allow to eventually print back any query.
This is useful e.g. for storage engines that take over diferrent kinds of
queries
*/
void
LEX
::
print
(
String
*
str
,
enum_query_type
query_type
)
{
if
(
sql_command
==
SQLCOM_UPDATE
)
{
SELECT_LEX
*
sel
=
first_select_lex
();
str
->
append
(
STRING_WITH_LEN
(
"UPDATE "
));
if
(
ignore
)
str
->
append
(
STRING_WITH_LEN
(
"IGNORE "
));
// table name
str
->
append
(
query_tables
->
alias
);
str
->
append
(
STRING_WITH_LEN
(
" SET "
));
// print item assignments
List_iterator
<
Item
>
it
(
sel
->
item_list
);
List_iterator
<
Item
>
it2
(
value_list
);
Item
*
col_ref
,
*
value
;
bool
first
=
true
;
while
((
col_ref
=
it
++
)
&&
(
value
=
it2
++
))
{
if
(
first
)
first
=
false
;
else
str
->
append
(
STRING_WITH_LEN
(
", "
));
col_ref
->
print
(
str
,
query_type
);
str
->
append
(
STRING_WITH_LEN
(
"="
));
value
->
print
(
str
,
query_type
);
}
str
->
append
(
STRING_WITH_LEN
(
" WHERE "
));
sel
->
where
->
print
(
str
,
query_type
);
if
(
sel
->
order_list
.
elements
)
{
str
->
append
(
STRING_WITH_LEN
(
" ORDER BY "
));
for
(
ORDER
*
ord
=
sel
->
order_list
.
first
;
ord
;
ord
=
ord
->
next
)
{
if
(
ord
!=
sel
->
order_list
.
first
)
str
->
append
(
STRING_WITH_LEN
(
", "
));
(
*
ord
->
item
)
->
print
(
str
,
query_type
);
}
}
if
(
sel
->
select_limit
)
{
str
->
append
(
STRING_WITH_LEN
(
" LIMIT "
));
sel
->
select_limit
->
print
(
str
,
query_type
);
}
}
else
DBUG_ASSERT
(
0
);
// Not implemented yet
}
void
st_select_lex_unit
::
print
(
String
*
str
,
enum_query_type
query_type
)
void
st_select_lex_unit
::
print
(
String
*
str
,
enum_query_type
query_type
)
{
{
if
(
with_clause
)
if
(
with_clause
)
...
...
sql/sql_lex.h
View file @
0a9633ee
...
@@ -3264,6 +3264,7 @@ struct LEX: public Query_tables_list
...
@@ -3264,6 +3264,7 @@ struct LEX: public Query_tables_list
void
reset_arena_for_set_stmt
(
Query_arena
*
backup
);
void
reset_arena_for_set_stmt
(
Query_arena
*
backup
);
void
free_arena_for_set_stmt
();
void
free_arena_for_set_stmt
();
void
print
(
String
*
str
,
enum_query_type
qtype
);
List
<
Item_func_set_user_var
>
set_var_list
;
// in-query assignment list
List
<
Item_func_set_user_var
>
set_var_list
;
// in-query assignment list
List
<
Item_param
>
param_list
;
List
<
Item_param
>
param_list
;
List
<
LEX_CSTRING
>
view_list
;
// view list (list of field names in view)
List
<
LEX_CSTRING
>
view_list
;
// view list (list of field names in view)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment