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
122ffa22
Commit
122ffa22
authored
Apr 27, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL(misc): Query_arena_stmt RAII
parent
1e8a81de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
12 deletions
+32
-12
sql/sql_class.cc
sql/sql_class.cc
+13
-0
sql/sql_class.h
sql/sql_class.h
+16
-0
sql/sql_derived.cc
sql/sql_derived.cc
+1
-4
sql/sql_select.cc
sql/sql_select.cc
+2
-8
No files found.
sql/sql_class.cc
View file @
122ffa22
...
...
@@ -7425,3 +7425,16 @@ bool Discrete_intervals_list::append(Discrete_interval *new_interval)
}
#endif
/* !defined(MYSQL_CLIENT) */
Query_arena_stmt
::
Query_arena_stmt
(
THD
*
_thd
)
:
thd
(
_thd
)
{
arena
=
thd
->
activate_stmt_arena_if_needed
(
&
backup
);
}
Query_arena_stmt
::~
Query_arena_stmt
()
{
if
(
arena
)
thd
->
restore_active_arena
(
arena
,
&
backup
);
}
sql/sql_class.h
View file @
122ffa22
...
...
@@ -1024,6 +1024,22 @@ class Query_arena_memroot: public Query_arena, public Sql_alloc
};
class
Query_arena_stmt
{
THD
*
thd
;
Query_arena
backup
;
Query_arena
*
arena
;
public:
Query_arena_stmt
(
THD
*
_thd
);
~
Query_arena_stmt
();
bool
arena_replaced
()
{
return
arena
!=
NULL
;
}
};
class
Server_side_cursor
;
/**
...
...
sql/sql_derived.cc
View file @
122ffa22
...
...
@@ -723,14 +723,11 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
TABLE_SHARE
*
s
=
tl
->
table
->
s
;
const
char
*
db
=
tl
->
db
;
const
char
*
alias
=
tl
->
alias
;
Query_arena
backup
;
Query_arena
*
arena
=
thd
->
activate_stmt_arena_if_needed
(
&
backup
);
Query_arena_stmt
on_stmt_arena
(
thd
);
sl
->
item_list
.
push_back
(
new
(
thd
->
mem_root
)
Item_field
(
thd
,
&
sl
->
context
,
db
,
alias
,
s
->
vers_start_field
()
->
field_name
));
sl
->
item_list
.
push_back
(
new
(
thd
->
mem_root
)
Item_field
(
thd
,
&
sl
->
context
,
db
,
alias
,
s
->
vers_end_field
()
->
field_name
));
if
(
arena
)
thd
->
restore_active_arena
(
arena
,
&
backup
);
}
}
}
...
...
sql/sql_select.cc
View file @
122ffa22
...
...
@@ -695,7 +695,6 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
TABLE_LIST
*
table
;
int
versioned_tables
=
0
;
int
slex_conds_used
=
0
;
Query_arena
*
arena
=
0
,
backup
;
if
(
!
thd
->
stmt_arena
->
is_conventional
()
&&
!
thd
->
stmt_arena
->
is_stmt_prepare
()
&&
!
thd
->
stmt_arena
->
is_sp_execute
())
...
...
@@ -727,7 +726,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
/* For prepared statements we create items on statement arena,
because they must outlive execution phase for multiple executions. */
arena
=
thd
->
activate_stmt_arena_if_needed
(
&
backup
);
Query_arena_stmt
on_stmt_arena
(
thd
);
if
(
slex
->
saved_where
)
{
...
...
@@ -798,8 +797,6 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
case
TL_WRITE
:
case
TL_WRITE_ONLY
:
my_error
(
ER_VERS_WRONG_PARAMS
,
MYF
(
0
),
"FOR SYSTEM_TIME query"
,
"write-locking of historic rows"
);
if
(
arena
)
thd
->
restore_active_arena
(
arena
,
&
backup
);
DBUG_RETURN
(
-
1
);
default:
break
;
...
...
@@ -969,7 +966,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
cond2
,
cond1
));
if
(
arena
)
if
(
on_stmt_arena
.
arena_replaced
()
)
*
dst_cond
=
cond1
;
else
thd
->
change_item_tree
(
dst_cond
,
cond1
);
...
...
@@ -977,9 +974,6 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
}
// if (... table->table->versioned())
}
// for (table= tables; ...)
if
(
arena
)
thd
->
restore_active_arena
(
arena
,
&
backup
);
if
(
!
slex_conds_used
&&
slex
->
vers_conditions
)
{
my_error
(
ER_VERS_WRONG_QUERY
,
MYF
(
0
),
"unused `QUERY FOR SYSTEM_TIME` clause!"
);
...
...
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