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
1fbbaa07
Commit
1fbbaa07
authored
Aug 15, 2019
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ccc
parent
417bd564
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
18 deletions
+80
-18
sql/sp_head.cc
sql/sp_head.cc
+40
-9
sql/sp_head.h
sql/sp_head.h
+23
-8
sql/sql_class.cc
sql/sql_class.cc
+4
-0
sql/sql_lex.cc
sql/sql_lex.cc
+9
-0
sql/sql_lex.h
sql/sql_lex.h
+3
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
sql/sp_head.cc
View file @
1fbbaa07
...
@@ -1042,7 +1042,7 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
...
@@ -1042,7 +1042,7 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
Copy_query_with_rewrite
acc
(
thd
,
query_str
->
str
,
query_str
->
length
,
&
qbuf
);
Copy_query_with_rewrite
acc
(
thd
,
query_str
->
str
,
query_str
->
length
,
&
qbuf
);
/* Find rewritable Items used in this statement */
/* Find rewritable Items used in this statement */
for
(
Item
*
item
=
instr
->
free_list
;
item
;
item
=
item
->
next
)
for
(
Item
*
item
=
instr
->
get_free_list
()
;
item
;
item
=
item
->
next
)
{
{
Rewritable_query_parameter
*
rqp
=
item
->
get_rewritable_query_parameter
();
Rewritable_query_parameter
*
rqp
=
item
->
get_rewritable_query_parameter
();
if
(
rqp
&&
rqp
->
pos_in_query
)
if
(
rqp
&&
rqp
->
pos_in_query
)
...
@@ -1333,7 +1333,8 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
...
@@ -1333,7 +1333,8 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
during the first execution (for example expanding of '*' or the
during the first execution (for example expanding of '*' or the
items made during other permanent subquery transformations).
items made during other permanent subquery transformations).
*/
*/
thd
->
stmt_arena
=
i
;
if
(
!
(
thd
->
stmt_arena
=
i
->
get_arena
()))
thd
->
stmt_arena
=
old_arena
;
/*
/*
Will write this SP statement into binlog separately.
Will write this SP statement into binlog separately.
...
@@ -1359,8 +1360,16 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
...
@@ -1359,8 +1360,16 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
thd
->
m_digest
=
parent_digest
;
thd
->
m_digest
=
parent_digest
;
if
(
i
->
free_list
)
{
cleanup_items
(
i
->
free_list
);
DBUG_PRINT
(
"YYY"
,
(
"free attempt"
));
Item
*
to_free
=
i
->
get_free_list
();
if
(
to_free
)
{
DBUG_PRINT
(
"YYY"
,
(
"free from arena %p %s"
,
i
->
get_arena
(),
i
->
get_arena
()
->
mem_root
->
name
));
cleanup_items
(
to_free
);
}
}
/*
/*
If we've set thd->user_var_events_alloc to mem_root of this SP
If we've set thd->user_var_events_alloc to mem_root of this SP
...
@@ -2403,6 +2412,10 @@ sp_head::reset_lex(THD *thd, sp_lex_local *sublex)
...
@@ -2403,6 +2412,10 @@ sp_head::reset_lex(THD *thd, sp_lex_local *sublex)
thd
->
set_local_lex
(
sublex
);
thd
->
set_local_lex
(
sublex
);
DBUG_ASSERT
(
thd
->
free_list
==
NULL
);
DBUG_ASSERT
(
thd
->
free_list
==
NULL
);
sp_lex_local
*
sp_lex
=
sublex
->
sp_lex_ref
();
if
(
sp_lex
)
sp_lex
->
set_arena
();
DBUG_RETURN
(
m_lex
.
push_front
(
oldlex
));
DBUG_RETURN
(
m_lex
.
push_front
(
oldlex
));
}
}
...
@@ -2431,8 +2444,7 @@ sp_head::restore_lex(THD *thd)
...
@@ -2431,8 +2444,7 @@ sp_head::restore_lex(THD *thd)
DBUG_RETURN
(
true
);
DBUG_RETURN
(
true
);
if
(
sp_lex
)
if
(
sp_lex
)
{
{
sp_lex
->
free_list
=
thd
->
free_list
;
sp_lex
->
restore_arena
();
thd
->
free_list
=
NULL
;
}
}
if
(
!
sublex
->
sp_lex_in_use
)
if
(
!
sublex
->
sp_lex_in_use
)
{
{
...
@@ -2446,11 +2458,13 @@ sp_head::restore_lex(THD *thd)
...
@@ -2446,11 +2458,13 @@ sp_head::restore_lex(THD *thd)
m_all_lexes
.
link_in_list
(
sp_lex
,
&
sp_lex
->
next_sublex
);
m_all_lexes
.
link_in_list
(
sp_lex
,
&
sp_lex
->
next_sublex
);
DBUG_PRINT
(
"info"
,
(
"%p added to %p head as # %u"
,
DBUG_PRINT
(
"info"
,
(
"%p added to %p head as # %u"
,
sp_lex
,
this
,
m_all_lexes
.
elements
));
sp_lex
,
this
,
m_all_lexes
.
elements
));
#ifndef DBUG_OFF
for
(
sp_lex_local
*
sl
=
m_all_lexes
.
first
;
sl
;
sl
=
sl
->
next_sublex
)
for
(
sp_lex_local
*
sl
=
m_all_lexes
.
first
;
sl
;
sl
=
sl
->
next_sublex
)
{
{
cnt
++
;
cnt
++
;
DBUG_PRINT
(
"XXX"
,
(
"# %u : %p"
,
cnt
,
sl
));
DBUG_PRINT
(
"XXX"
,
(
"# %u : %p"
,
cnt
,
sl
));
}
}
#endif
/*DBUG_OFF*/
DBUG_ASSERT
(
cnt
==
m_all_lexes
.
elements
);
DBUG_ASSERT
(
cnt
==
m_all_lexes
.
elements
);
}
}
...
@@ -3025,15 +3039,16 @@ sp_head::show_create_routine(THD *thd, const Sp_handler *sph)
...
@@ -3025,15 +3039,16 @@ sp_head::show_create_routine(THD *thd, const Sp_handler *sph)
int
sp_head
::
add_instr
(
sp_instr
*
instr
)
int
sp_head
::
add_instr
(
sp_instr
*
instr
)
{
{
instr
->
free_list
=
m_thd
->
free_list
;
//instr->free_list= m_thd->free_list;
m_thd
->
free_list
=
0
;
//m_thd->free_list= 0;
//DBUG_ASSERT(m_thd->free_list == 0 || );
/*
/*
Memory root of every instruction is designated for permanent
Memory root of every instruction is designated for permanent
transformations (optimizations) made on the parsed tree during
transformations (optimizations) made on the parsed tree during
the first execution. It points to the memory root of the
the first execution. It points to the memory root of the
entire stored procedure, as their life span is equal.
entire stored procedure, as their life span is equal.
*/
*/
instr
->
mem_root
=
&
main_mem_root
;
//
instr->mem_root= &main_mem_root;
instr
->
m_lineno
=
m_thd
->
m_parser_state
->
m_lip
.
yylineno
;
instr
->
m_lineno
=
m_thd
->
m_parser_state
->
m_lip
.
yylineno
;
return
insert_dynamic
(
&
m_instr
,
(
uchar
*
)
&
instr
);
return
insert_dynamic
(
&
m_instr
,
(
uchar
*
)
&
instr
);
}
}
...
@@ -3492,6 +3507,12 @@ int sp_lex_keeper::cursor_reset_lex_and_exec_core(THD *thd, uint *nextp,
...
@@ -3492,6 +3507,12 @@ int sp_lex_keeper::cursor_reset_lex_and_exec_core(THD *thd, uint *nextp,
}
}
Query_arena
*
sp_lex_keeper
::
get_arena
()
{
return
m_lex
->
sp_lex_ref
();
}
/*
/*
sp_instr class functions
sp_instr class functions
*/
*/
...
@@ -4380,6 +4401,16 @@ sp_instr_copen::execute(THD *thd, uint *nextp)
...
@@ -4380,6 +4401,16 @@ sp_instr_copen::execute(THD *thd, uint *nextp)
sp_lex_keeper
*
lex_keeper
=
c
->
get_lex_keeper
();
sp_lex_keeper
*
lex_keeper
=
c
->
get_lex_keeper
();
res
=
lex_keeper
->
cursor_reset_lex_and_exec_core
(
thd
,
nextp
,
FALSE
,
this
);
res
=
lex_keeper
->
cursor_reset_lex_and_exec_core
(
thd
,
nextp
,
FALSE
,
this
);
/* TODO: Assert here that we either have an error or a cursor */
/* TODO: Assert here that we either have an error or a cursor */
Query_arena
*
arena
=
lex_keeper
->
get_arena
();
Item
*
to_free
=
(
arena
?
arena
->
free_list
:
0
);
if
(
to_free
)
{
DBUG_PRINT
(
"YYY"
,
(
"free from cursor arena %p %s"
,
arena
,
arena
->
mem_root
->
name
));
cleanup_items
(
to_free
);
}
}
}
DBUG_RETURN
(
res
);
DBUG_RETURN
(
res
);
}
}
...
...
sql/sp_head.h
View file @
1fbbaa07
...
@@ -1034,7 +1034,7 @@ class sp_lex_cursor: public sp_lex_local
...
@@ -1034,7 +1034,7 @@ class sp_lex_cursor: public sp_lex_local
// "Instructions"...
// "Instructions"...
//
//
class
sp_instr
:
public
Query_arena
,
public
Sql_alloc
class
sp_instr
:
public
Sql_alloc
{
{
sp_instr
(
const
sp_instr
&
);
/**< Prevent use of these */
sp_instr
(
const
sp_instr
&
);
/**< Prevent use of these */
void
operator
=
(
sp_instr
&
);
void
operator
=
(
sp_instr
&
);
...
@@ -1048,11 +1048,20 @@ class sp_instr :public Query_arena, public Sql_alloc
...
@@ -1048,11 +1048,20 @@ class sp_instr :public Query_arena, public Sql_alloc
/// Should give each a name or type code for debugging purposes?
/// Should give each a name or type code for debugging purposes?
sp_instr
(
uint
ip
,
sp_pcontext
*
ctx
)
sp_instr
(
uint
ip
,
sp_pcontext
*
ctx
)
:
Query_arena
(
0
,
STMT_INITIALIZED_FOR_SP
),
marked
(
0
),
m_ip
(
ip
),
m_ctx
(
ctx
)
:
marked
(
0
),
m_ip
(
ip
),
m_ctx
(
ctx
)
{}
{}
virtual
~
sp_instr
()
virtual
~
sp_instr
()
{
free_items
();
}
{}
virtual
Query_arena
*
get_arena
()
{
return
0
;
}
Item
*
get_free_list
()
{
Query_arena
*
arena
=
get_arena
();
if
(
arena
)
return
arena
->
free_list
;
return
NULL
;
}
/**
/**
...
@@ -1200,6 +1209,8 @@ class sp_lex_keeper
...
@@ -1200,6 +1209,8 @@ class sp_lex_keeper
m_lex
->
safe_to_cache_query
=
0
;
m_lex
->
safe_to_cache_query
=
0
;
}
}
Query_arena
*
get_arena
();
private:
private:
//sp_lex_keeper *next;
//sp_lex_keeper *next;
LEX
*
m_lex
;
LEX
*
m_lex
;
...
@@ -1245,6 +1256,8 @@ class sp_lex_basic_instr : public sp_instr
...
@@ -1245,6 +1256,8 @@ class sp_lex_basic_instr : public sp_instr
sp_lex_basic_instr
(
uint
ip
,
sp_pcontext
*
ctx
,
LEX
*
lex
,
bool
lex_owner
)
sp_lex_basic_instr
(
uint
ip
,
sp_pcontext
*
ctx
,
LEX
*
lex
,
bool
lex_owner
)
:
sp_instr
(
ip
,
ctx
),
m_lex_keeper
(
lex
,
lex_owner
)
:
sp_instr
(
ip
,
ctx
),
m_lex_keeper
(
lex
,
lex_owner
)
{}
{}
virtual
Query_arena
*
get_arena
()
{
return
m_lex_keeper
.
get_arena
();
}
};
};
/**
/**
...
@@ -1275,7 +1288,7 @@ class sp_instr_stmt : public sp_lex_basic_instr
...
@@ -1275,7 +1288,7 @@ class sp_instr_stmt : public sp_lex_basic_instr
virtual
void
print
(
String
*
str
);
virtual
void
print
(
String
*
str
);
};
// class sp_instr_stmt
: public sp_instr
};
// class sp_instr_stmt
class
sp_instr_set
:
public
sp_lex_basic_instr
class
sp_instr_set
:
public
sp_lex_basic_instr
...
@@ -1307,7 +1320,7 @@ class sp_instr_set : public sp_lex_basic_instr
...
@@ -1307,7 +1320,7 @@ class sp_instr_set : public sp_lex_basic_instr
const
Sp_rcontext_handler
*
m_rcontext_handler
;
const
Sp_rcontext_handler
*
m_rcontext_handler
;
uint
m_offset
;
///< Frame offset
uint
m_offset
;
///< Frame offset
Item
*
m_value
;
Item
*
m_value
;
};
// class sp_instr_set
: public sp_instr
};
// class sp_instr_set
/*
/*
...
@@ -1414,7 +1427,7 @@ class sp_instr_set_trigger_field : public sp_lex_basic_instr
...
@@ -1414,7 +1427,7 @@ class sp_instr_set_trigger_field : public sp_lex_basic_instr
private:
private:
Item_trigger_field
*
trigger_field
;
Item_trigger_field
*
trigger_field
;
Item
*
value
;
Item
*
value
;
};
// class sp_instr_trigger_field
: public sp_instr
};
// class sp_instr_trigger_field
/**
/**
...
@@ -1546,6 +1559,8 @@ class sp_instr_jump_if_not : public sp_instr_jump
...
@@ -1546,6 +1559,8 @@ class sp_instr_jump_if_not : public sp_instr_jump
m_cont_dest
=
new_dest
;
m_cont_dest
=
new_dest
;
}
}
virtual
Query_arena
*
get_arena
()
{
return
m_lex_keeper
.
get_arena
();
}
private:
private:
Item
*
m_expr
;
///< The condition
Item
*
m_expr
;
///< The condition
...
@@ -1621,7 +1636,7 @@ class sp_instr_freturn : public sp_lex_basic_instr
...
@@ -1621,7 +1636,7 @@ class sp_instr_freturn : public sp_lex_basic_instr
Item
*
m_value
;
Item
*
m_value
;
const
Type_handler
*
m_type_handler
;
const
Type_handler
*
m_type_handler
;
};
// class sp_instr_freturn
: public sp_instr
};
// class sp_instr_freturn
class
sp_instr_hpush_jump
:
public
sp_instr_jump
class
sp_instr_hpush_jump
:
public
sp_instr_jump
...
@@ -1783,7 +1798,7 @@ class sp_instr_cpush : public sp_lex_basic_instr,
...
@@ -1783,7 +1798,7 @@ class sp_instr_cpush : public sp_lex_basic_instr,
uint
m_cursor
;
/**< Frame offset (for debugging) */
uint
m_cursor
;
/**< Frame offset (for debugging) */
};
// class sp_instr_cpush
: public sp_instr
};
// class sp_instr_cpush
class
sp_instr_cpop
:
public
sp_instr
class
sp_instr_cpop
:
public
sp_instr
...
...
sql/sql_class.cc
View file @
1fbbaa07
...
@@ -3899,6 +3899,8 @@ void THD::set_n_backup_active_arena(Query_arena *set, Query_arena *backup)
...
@@ -3899,6 +3899,8 @@ void THD::set_n_backup_active_arena(Query_arena *set, Query_arena *backup)
{
{
DBUG_ENTER
(
"THD::set_n_backup_active_arena"
);
DBUG_ENTER
(
"THD::set_n_backup_active_arena"
);
DBUG_ASSERT
(
backup
->
is_backup_arena
==
FALSE
);
DBUG_ASSERT
(
backup
->
is_backup_arena
==
FALSE
);
DBUG_PRINT
(
"XXX"
,
(
"set arena %p (%s > %s) backup %p"
,
set
,
this
->
mem_root
->
name
,
set
->
mem_root
->
name
,
backup
));
backup
->
set_query_arena
(
this
);
backup
->
set_query_arena
(
this
);
set_query_arena
(
set
);
set_query_arena
(
set
);
...
@@ -3919,6 +3921,8 @@ void THD::restore_active_arena(Query_arena *set, Query_arena *backup)
...
@@ -3919,6 +3921,8 @@ void THD::restore_active_arena(Query_arena *set, Query_arena *backup)
{
{
DBUG_ENTER
(
"THD::restore_active_arena"
);
DBUG_ENTER
(
"THD::restore_active_arena"
);
DBUG_ASSERT
(
backup
->
is_backup_arena
);
DBUG_ASSERT
(
backup
->
is_backup_arena
);
DBUG_PRINT
(
"XXX"
,
(
"restore arena %p (%s) backup %p (%s)"
,
set
,
set
->
mem_root
->
name
,
backup
,
backup
->
mem_root
->
name
));
set
->
set_query_arena
(
this
);
set
->
set_query_arena
(
this
);
set_query_arena
(
backup
);
set_query_arena
(
backup
);
#ifdef DBUG_ASSERT_EXISTS
#ifdef DBUG_ASSERT_EXISTS
...
...
sql/sql_lex.cc
View file @
1fbbaa07
...
@@ -10518,3 +10518,12 @@ void sp_lex_local::operator delete(void *ptr, size_t size) throw()
...
@@ -10518,3 +10518,12 @@ void sp_lex_local::operator delete(void *ptr, size_t size) throw()
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
void
sp_lex_local
::
set_arena
()
{
thd
->
set_n_backup_active_arena
(
this
,
&
backup_arena
);
}
void
sp_lex_local
::
restore_arena
()
{
thd
->
restore_active_arena
(
this
,
&
backup_arena
);
}
sql/sql_lex.h
View file @
1fbbaa07
...
@@ -4764,6 +4764,7 @@ class sp_lex_local: public sp_lex, public Query_arena
...
@@ -4764,6 +4764,7 @@ class sp_lex_local: public sp_lex, public Query_arena
void
operator
=
(
sp_lex_local
&
);
void
operator
=
(
sp_lex_local
&
);
protected:
protected:
MEM_ROOT
main_mem_root
;
MEM_ROOT
main_mem_root
;
Query_arena
backup_arena
;
public:
public:
sp_lex_local
*
next_sublex
;
// link in sp LEXs (m_all_lexes) list
sp_lex_local
*
next_sublex
;
// link in sp LEXs (m_all_lexes) list
...
@@ -4776,6 +4777,8 @@ class sp_lex_local: public sp_lex, public Query_arena
...
@@ -4776,6 +4777,8 @@ class sp_lex_local: public sp_lex, public Query_arena
{
{
free_items
();
free_items
();
}
}
void
set_arena
();
void
restore_arena
();
sp_lex_local
*
sp_lex_ref
()
{
return
this
;
}
sp_lex_local
*
sp_lex_ref
()
{
return
this
;
}
};
};
...
...
sql/sql_yacc.yy
View file @
1fbbaa07
...
@@ -515,7 +515,7 @@ bool sp_create_assignment_lex(THD *thd, const char *pos)
...
@@ -515,7 +515,7 @@ bool sp_create_assignment_lex(THD *thd, const char *pos)
if (thd->lex->sphead)
if (thd->lex->sphead)
{
{
sp_lex_local *new_lex;
sp_lex_local *new_lex;
if (!(new_lex= new
(thd->mem_root)
sp_lex_set_var(thd, thd->lex)) ||
if (!(new_lex= new sp_lex_set_var(thd, thd->lex)) ||
new_lex->main_select_push())
new_lex->main_select_push())
return true;
return true;
new_lex->sphead->m_tmp_query= pos;
new_lex->sphead->m_tmp_query= pos;
...
...
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