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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8b9bf757
Commit
8b9bf757
authored
Jun 22, 2005
by
konstantin@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/opt/local/work/mysql-5.0-10736-new
parents
975cbd82
dc7aa03e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
81 deletions
+42
-81
sql/sp_head.cc
sql/sp_head.cc
+2
-2
sql/sp_head.h
sql/sp_head.h
+1
-0
sql/sql_class.cc
sql/sql_class.cc
+19
-63
sql/sql_class.h
sql/sql_class.h
+7
-13
sql/sql_prepare.cc
sql/sql_prepare.cc
+1
-1
sql/sql_select.cc
sql/sql_select.cc
+10
-1
sql/sql_select.h
sql/sql_select.h
+2
-1
No files found.
sql/sp_head.cc
View file @
8b9bf757
...
@@ -310,7 +310,8 @@ sp_head::operator delete(void *ptr, size_t size)
...
@@ -310,7 +310,8 @@ sp_head::operator delete(void *ptr, size_t size)
sp_head
::
sp_head
()
sp_head
::
sp_head
()
:
Query_arena
((
bool
)
FALSE
),
m_returns_cs
(
NULL
),
m_has_return
(
FALSE
),
:
Query_arena
(
&
main_mem_root
,
INITIALIZED_FOR_SP
),
m_returns_cs
(
NULL
),
m_has_return
(
FALSE
),
m_simple_case
(
FALSE
),
m_multi_results
(
FALSE
),
m_in_handler
(
FALSE
)
m_simple_case
(
FALSE
),
m_multi_results
(
FALSE
),
m_in_handler
(
FALSE
)
{
{
extern
byte
*
extern
byte
*
...
@@ -319,7 +320,6 @@ sp_head::sp_head()
...
@@ -319,7 +320,6 @@ sp_head::sp_head()
*
sp_lex_sp_key
(
const
byte
*
ptr
,
uint
*
plen
,
my_bool
first
);
*
sp_lex_sp_key
(
const
byte
*
ptr
,
uint
*
plen
,
my_bool
first
);
DBUG_ENTER
(
"sp_head::sp_head"
);
DBUG_ENTER
(
"sp_head::sp_head"
);
state
=
INITIALIZED_FOR_SP
;
m_backpatch
.
empty
();
m_backpatch
.
empty
();
m_lex
.
empty
();
m_lex
.
empty
();
hash_init
(
&
m_sptabs
,
system_charset_info
,
0
,
0
,
0
,
sp_table_key
,
0
,
0
);
hash_init
(
&
m_sptabs
,
system_charset_info
,
0
,
0
,
0
,
sp_table_key
,
0
,
0
);
...
...
sql/sp_head.h
View file @
8b9bf757
...
@@ -79,6 +79,7 @@ class sp_head :private Query_arena
...
@@ -79,6 +79,7 @@ class sp_head :private Query_arena
sp_head
(
const
sp_head
&
);
/* Prevent use of these */
sp_head
(
const
sp_head
&
);
/* Prevent use of these */
void
operator
=
(
sp_head
&
);
void
operator
=
(
sp_head
&
);
MEM_ROOT
main_mem_root
;
public:
public:
int
m_type
;
// TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
int
m_type
;
// TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
...
...
sql/sql_class.cc
View file @
8b9bf757
...
@@ -420,8 +420,6 @@ THD::~THD()
...
@@ -420,8 +420,6 @@ THD::~THD()
#ifndef DBUG_OFF
#ifndef DBUG_OFF
dbug_sentry
=
THD_SENTRY_GONE
;
dbug_sentry
=
THD_SENTRY_GONE
;
#endif
#endif
/* Reset stmt_backup.mem_root to not double-free memory from thd.mem_root */
clear_alloc_root
(
&
stmt_backup
.
main_mem_root
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -1474,52 +1472,6 @@ void select_dumpvar::cleanup()
...
@@ -1474,52 +1472,6 @@ void select_dumpvar::cleanup()
}
}
/*
Create arena for already constructed THD.
SYNOPSYS
Query_arena()
thd - thread for which arena is created
DESCRIPTION
Create arena for already existing THD using its variables as parameters
for memory root initialization.
*/
Query_arena
::
Query_arena
(
THD
*
thd
)
:
free_list
(
0
),
mem_root
(
&
main_mem_root
),
state
(
INITIALIZED
)
{
init_sql_alloc
(
&
main_mem_root
,
thd
->
variables
.
query_alloc_block_size
,
thd
->
variables
.
query_prealloc_size
);
}
/*
Create arena and optionally initialize memory root.
SYNOPSYS
Query_arena()
init_mem_root - whenever we need to initialize memory root
DESCRIPTION
Create arena and optionally initialize memory root with minimal
possible parameters.
NOTE
We use this constructor when arena is part of THD, but reinitialize
its memory root in THD::init_for_queries() before execution of real
statements.
*/
Query_arena
::
Query_arena
(
bool
init_mem_root
)
:
free_list
(
0
),
mem_root
(
&
main_mem_root
),
state
(
CONVENTIONAL_EXECUTION
)
{
if
(
init_mem_root
)
init_sql_alloc
(
&
main_mem_root
,
ALLOC_ROOT_MIN_BLOCK_SIZE
,
0
);
}
Query_arena
::
Type
Query_arena
::
type
()
const
Query_arena
::
Type
Query_arena
::
type
()
const
{
{
DBUG_ASSERT
(
0
);
/* Should never be called */
DBUG_ASSERT
(
0
);
/* Should never be called */
...
@@ -1532,7 +1484,7 @@ Query_arena::Type Query_arena::type() const
...
@@ -1532,7 +1484,7 @@ Query_arena::Type Query_arena::type() const
*/
*/
Statement
::
Statement
(
THD
*
thd
)
Statement
::
Statement
(
THD
*
thd
)
:
Query_arena
(
thd
),
:
Query_arena
(
&
main_mem_root
,
INITIALIZED
),
id
(
++
thd
->
statement_id_counter
),
id
(
++
thd
->
statement_id_counter
),
set_query_id
(
1
),
set_query_id
(
1
),
allow_sum_func
(
0
),
allow_sum_func
(
0
),
...
@@ -1542,16 +1494,19 @@ Statement::Statement(THD *thd)
...
@@ -1542,16 +1494,19 @@ Statement::Statement(THD *thd)
cursor
(
0
)
cursor
(
0
)
{
{
name
.
str
=
NULL
;
name
.
str
=
NULL
;
init_sql_alloc
(
&
main_mem_root
,
thd
->
variables
.
query_alloc_block_size
,
thd
->
variables
.
query_prealloc_size
);
}
}
/*
/*
This constructor is called when
statement is a subobject of THD:
This constructor is called when
Statement is a parent of THD and
Some variables are initialized in THD::init due to locking problems
for the backup statement. Some variables are initialized in
T
his statement object will be used to
T
HD::init due to locking problems.
*/
*/
Statement
::
Statement
()
Statement
::
Statement
()
:
Query_arena
(
(
bool
)
TRUE
),
:
Query_arena
(
&
main_mem_root
,
CONVENTIONAL_EXECUTION
),
id
(
0
),
id
(
0
),
set_query_id
(
1
),
set_query_id
(
1
),
allow_sum_func
(
0
),
/* initialized later */
allow_sum_func
(
0
),
/* initialized later */
...
@@ -1560,6 +1515,12 @@ Statement::Statement()
...
@@ -1560,6 +1515,12 @@ Statement::Statement()
query_length
(
0
),
/* in alloc_query() */
query_length
(
0
),
/* in alloc_query() */
cursor
(
0
)
cursor
(
0
)
{
{
/*
This is just to ensure that the destructor works correctly in
case of an error and the backup statement. The memory root will
be re-initialized in THD::init.
*/
init_sql_alloc
(
&
main_mem_root
,
ALLOC_ROOT_MIN_BLOCK_SIZE
,
0
);
}
}
...
@@ -1631,16 +1592,6 @@ void Query_arena::restore_backup_item_arena(Query_arena *set, Query_arena *backu
...
@@ -1631,16 +1592,6 @@ void Query_arena::restore_backup_item_arena(Query_arena *set, Query_arena *backu
set_item_arena
(
backup
);
set_item_arena
(
backup
);
#ifndef DBUG_OFF
#ifndef DBUG_OFF
backup_arena
=
0
;
backup_arena
=
0
;
#endif
#ifdef NOT_NEEDED_NOW
/*
Reset backup mem_root to avoid its freeing.
Since Query_arena's mem_root is freed only when it is part of Statement
we need this only if we use some Statement's arena as backup storage.
But we do this only with THD::stmt_backup and this Statement is specially
handled in this respect. So this code is not really needed now.
*/
clear_alloc_root
(
&
backup
->
mem_root
);
#endif
#endif
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -1654,6 +1605,11 @@ void Query_arena::set_item_arena(Query_arena *set)
...
@@ -1654,6 +1605,11 @@ void Query_arena::set_item_arena(Query_arena *set)
Statement
::~
Statement
()
Statement
::~
Statement
()
{
{
/*
We must free `main_mem_root', not `mem_root' (pointer), to work
correctly if this statement is used as a backup statement,
for which `mem_root' may point to some other statement.
*/
free_root
(
&
main_mem_root
,
MYF
(
0
));
free_root
(
&
main_mem_root
,
MYF
(
0
));
}
}
...
...
sql/sql_class.h
View file @
8b9bf757
...
@@ -661,7 +661,6 @@ public:
...
@@ -661,7 +661,6 @@ public:
itself to the list on creation (see Item::Item() for details))
itself to the list on creation (see Item::Item() for details))
*/
*/
Item
*
free_list
;
Item
*
free_list
;
MEM_ROOT
main_mem_root
;
MEM_ROOT
*
mem_root
;
// Pointer to current memroot
MEM_ROOT
*
mem_root
;
// Pointer to current memroot
#ifndef DBUG_OFF
#ifndef DBUG_OFF
bool
backup_arena
;
bool
backup_arena
;
...
@@ -680,21 +679,14 @@ public:
...
@@ -680,21 +679,14 @@ public:
STATEMENT
,
PREPARED_STATEMENT
,
STORED_PROCEDURE
STATEMENT
,
PREPARED_STATEMENT
,
STORED_PROCEDURE
};
};
Query_arena
(
MEM_ROOT
*
mem_root_arg
,
enum
enum_state
state_arg
)
:
free_list
(
0
),
mem_root
(
mem_root_arg
),
state
(
state_arg
)
{}
/*
/*
This constructor is used only when Query_arena is created as
This constructor is used only when Query_arena is created as
backup storage for another instance of Query_arena.
backup storage for another instance of Query_arena.
*/
*/
Query_arena
()
{};
Query_arena
()
{};
/*
Create arena for already constructed THD using its variables as
parameters for memory root initialization.
*/
Query_arena
(
THD
*
thd
);
/*
Create arena and optionally init memory root with minimal values.
Particularly used if Query_arena is part of Statement.
*/
Query_arena
(
bool
init_mem_root
);
virtual
Type
type
()
const
;
virtual
Type
type
()
const
;
virtual
~
Query_arena
()
{};
virtual
~
Query_arena
()
{};
...
@@ -708,6 +700,7 @@ public:
...
@@ -708,6 +700,7 @@ public:
{
return
state
==
PREPARED
||
state
==
EXECUTED
;
}
{
return
state
==
PREPARED
||
state
==
EXECUTED
;
}
inline
bool
is_conventional
()
const
inline
bool
is_conventional
()
const
{
return
state
==
CONVENTIONAL_EXECUTION
;
}
{
return
state
==
CONVENTIONAL_EXECUTION
;
}
inline
gptr
alloc
(
unsigned
int
size
)
{
return
alloc_root
(
mem_root
,
size
);
}
inline
gptr
alloc
(
unsigned
int
size
)
{
return
alloc_root
(
mem_root
,
size
);
}
inline
gptr
calloc
(
unsigned
int
size
)
inline
gptr
calloc
(
unsigned
int
size
)
{
{
...
@@ -757,7 +750,8 @@ class Statement: public Query_arena
...
@@ -757,7 +750,8 @@ class Statement: public Query_arena
Statement
(
const
Statement
&
rhs
);
/* not implemented: */
Statement
(
const
Statement
&
rhs
);
/* not implemented: */
Statement
&
operator
=
(
const
Statement
&
rhs
);
/* non-copyable */
Statement
&
operator
=
(
const
Statement
&
rhs
);
/* non-copyable */
public:
public:
/* FIXME: must be private */
/* FIXME: these must be protected */
MEM_ROOT
main_mem_root
;
LEX
main_lex
;
LEX
main_lex
;
/*
/*
...
@@ -1388,7 +1382,7 @@ public:
...
@@ -1388,7 +1382,7 @@ public:
already changed to use this arena.
already changed to use this arena.
*/
*/
if
(
!
current_arena
->
is_conventional
()
&&
if
(
!
current_arena
->
is_conventional
()
&&
mem_root
!=
&
current_arena
->
main_
mem_root
)
mem_root
!=
current_arena
->
mem_root
)
{
{
set_n_backup_item_arena
(
current_arena
,
backup
);
set_n_backup_item_arena
(
current_arena
,
backup
);
return
current_arena
;
return
current_arena
;
...
...
sql/sql_prepare.cc
View file @
8b9bf757
...
@@ -2002,7 +2002,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
...
@@ -2002,7 +2002,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
{
{
DBUG_PRINT
(
"info"
,(
"Using READ_ONLY cursor"
));
DBUG_PRINT
(
"info"
,(
"Using READ_ONLY cursor"
));
if
(
!
cursor
&&
if
(
!
cursor
&&
!
(
cursor
=
stmt
->
cursor
=
new
(
&
stmt
->
main_mem_root
)
Cursor
(
)))
!
(
cursor
=
stmt
->
cursor
=
new
(
stmt
->
mem_root
)
Cursor
(
thd
)))
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
/* If lex->result is set, mysql_execute_command will use it */
/* If lex->result is set, mysql_execute_command will use it */
stmt
->
lex
->
result
=
&
cursor
->
result
;
stmt
->
lex
->
result
=
&
cursor
->
result
;
...
...
sql/sql_select.cc
View file @
8b9bf757
...
@@ -1708,7 +1708,16 @@ JOIN::cleanup()
...
@@ -1708,7 +1708,16 @@ JOIN::cleanup()
/************************* Cursor ******************************************/
/************************* Cursor ******************************************/
Cursor
::
Cursor
(
THD
*
thd
)
:
Query_arena
(
&
main_mem_root
,
INITIALIZED
),
join
(
0
),
unit
(
0
)
{
/* We will overwrite it at open anyway. */
init_sql_alloc
(
&
main_mem_root
,
ALLOC_ROOT_MIN_BLOCK_SIZE
,
0
);
}
void
void
Cursor
::
init_from_thd
(
THD
*
thd
)
Cursor
::
init_from_thd
(
THD
*
thd
)
{
{
...
...
sql/sql_select.h
View file @
8b9bf757
...
@@ -372,6 +372,7 @@ class JOIN :public Sql_alloc
...
@@ -372,6 +372,7 @@ class JOIN :public Sql_alloc
class
Cursor
:
public
Sql_alloc
,
public
Query_arena
class
Cursor
:
public
Sql_alloc
,
public
Query_arena
{
{
MEM_ROOT
main_mem_root
;
JOIN
*
join
;
JOIN
*
join
;
SELECT_LEX_UNIT
*
unit
;
SELECT_LEX_UNIT
*
unit
;
...
@@ -396,7 +397,7 @@ public:
...
@@ -396,7 +397,7 @@ public:
void
close
();
void
close
();
void
set_unit
(
SELECT_LEX_UNIT
*
unit_arg
)
{
unit
=
unit_arg
;
}
void
set_unit
(
SELECT_LEX_UNIT
*
unit_arg
)
{
unit
=
unit_arg
;
}
Cursor
(
)
:
Query_arena
(
TRUE
),
join
(
0
),
unit
(
0
)
{}
Cursor
(
THD
*
thd
);
~
Cursor
();
~
Cursor
();
};
};
...
...
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