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
2c14bd9a
Commit
2c14bd9a
authored
Jun 22, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge pgalbraith@bk-internal.mysql.com:/home/bk/mysql-5.0
into radha.local:/Volumes/disk2s1/mysql-5.0
parents
c09ca7d8
60d6b877
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
60 deletions
+39
-60
sql/sql_class.cc
sql/sql_class.cc
+12
-31
sql/sql_class.h
sql/sql_class.h
+4
-11
sql/sql_prepare.cc
sql/sql_prepare.cc
+20
-16
sql/sql_select.cc
sql/sql_select.cc
+3
-2
No files found.
sql/sql_class.cc
View file @
2c14bd9a
...
...
@@ -156,9 +156,15 @@ bool foreign_key_prefix(Key *a, Key *b)
/****************************************************************************
** Thread specific functions
****************************************************************************/
/*
Pass nominal parameters to Statement constructor only to ensure that
the destructor works OK in case of error. The main_mem_root will be
re-initialized in init().
*/
THD
::
THD
()
:
user_time
(
0
),
global_read_lock
(
0
),
is_fatal_error
(
0
),
:
Statement
(
CONVENTIONAL_EXECUTION
,
0
,
ALLOC_ROOT_MIN_BLOCK_SIZE
,
0
),
user_time
(
0
),
global_read_lock
(
0
),
is_fatal_error
(
0
),
rand_used
(
0
),
time_zone_used
(
0
),
last_insert_id_used
(
0
),
insert_id_used
(
0
),
clear_next_insert_id
(
0
),
in_lock_tables
(
0
),
bootstrap
(
0
),
derived_tables_processing
(
FALSE
),
...
...
@@ -1483,9 +1489,10 @@ Query_arena::Type Query_arena::type() const
Statement functions
*/
Statement
::
Statement
(
THD
*
thd
)
:
Query_arena
(
&
main_mem_root
,
INITIALIZED
),
id
(
++
thd
->
statement_id_counter
),
Statement
::
Statement
(
enum
enum_state
state_arg
,
ulong
id_arg
,
ulong
alloc_block_size
,
ulong
prealloc_size
)
:
Query_arena
(
&
main_mem_root
,
state_arg
),
id
(
id_arg
),
set_query_id
(
1
),
allow_sum_func
(
0
),
lex
(
&
main_lex
),
...
...
@@ -1494,33 +1501,7 @@ Statement::Statement(THD *thd)
cursor
(
0
)
{
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 parent of THD and
for the backup statement. Some variables are initialized in
THD::init due to locking problems.
*/
Statement
::
Statement
()
:
Query_arena
(
&
main_mem_root
,
CONVENTIONAL_EXECUTION
),
id
(
0
),
set_query_id
(
1
),
allow_sum_func
(
0
),
/* initialized later */
lex
(
&
main_lex
),
query
(
0
),
/* these two are set */
query_length
(
0
),
/* in alloc_query() */
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
);
init_sql_alloc
(
&
main_mem_root
,
alloc_block_size
,
prealloc_size
);
}
...
...
sql/sql_class.h
View file @
2c14bd9a
...
...
@@ -809,13 +809,11 @@ public:
public:
/*
This constructor is called when statement is a subobject of THD:
some variables are initialized in THD::init due to locking problems
*/
Statement
();
/* This constructor is called for backup statements */
Statement
()
{
clear_alloc_root
(
&
main_mem_root
);
}
Statement
(
THD
*
thd
);
Statement
(
enum
enum_state
state_arg
,
ulong
id_arg
,
ulong
alloc_block_size
,
ulong
prealloc_size
);
virtual
~
Statement
();
/* Assign execution context (note: not all members) of given stmt to self */
...
...
@@ -957,11 +955,6 @@ public:
pthread_mutex_t
LOCK_delete
;
// Locked before thd is deleted
/* all prepared statements and cursors of this connection */
Statement_map
stmt_map
;
/*
keeps THD state while it is used for active statement
Note: we perform special cleanup for it in THD destructor.
*/
Statement
stmt_backup
;
/*
A pointer to the stack frame of handle_one_connection(),
which is called first in the thread for handling a client
...
...
sql/sql_prepare.cc
View file @
2c14bd9a
...
...
@@ -1706,6 +1706,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
LEX_STRING
*
name
)
{
LEX
*
lex
;
Statement
stmt_backup
;
Prepared_statement
*
stmt
=
new
Prepared_statement
(
thd
);
bool
error
;
DBUG_ENTER
(
"mysql_stmt_prepare"
);
...
...
@@ -1739,13 +1740,13 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
DBUG_RETURN
(
TRUE
);
}
thd
->
set_n_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
set_n_backup_item_arena
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
set_n_backup_statement
(
stmt
,
&
stmt_backup
);
thd
->
set_n_backup_item_arena
(
stmt
,
&
stmt_backup
);
if
(
alloc_query
(
thd
,
packet
,
packet_length
))
{
thd
->
restore_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_item_arena
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_statement
(
stmt
,
&
stmt_backup
);
thd
->
restore_backup_item_arena
(
stmt
,
&
stmt_backup
);
/* Statement map deletes statement on erase */
thd
->
stmt_map
.
erase
(
stmt
);
DBUG_RETURN
(
TRUE
);
...
...
@@ -1770,7 +1771,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
transformation can be reused on execute, we set again thd->mem_root from
stmt->mem_root (see setup_wild for one place where we do that).
*/
thd
->
restore_backup_item_arena
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_item_arena
(
stmt
,
&
stmt_backup
);
if
(
!
error
)
error
=
check_prepared_statement
(
stmt
,
test
(
name
));
...
...
@@ -1786,7 +1787,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
lex_end
(
lex
);
close_thread_tables
(
thd
);
cleanup_stmt_and_thd_after_use
(
stmt
,
thd
);
thd
->
restore_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_statement
(
stmt
,
&
stmt_backup
);
thd
->
current_arena
=
thd
;
if
(
error
)
...
...
@@ -1949,6 +1950,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
{
ulong
stmt_id
=
uint4korr
(
packet
);
ulong
flags
=
(
ulong
)
((
uchar
)
packet
[
4
]);
Statement
stmt_backup
;
Cursor
*
cursor
;
/*
Query text for binary log, or empty string if the query is not put into
...
...
@@ -2026,8 +2028,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
if
(
stmt
->
param_count
&&
stmt
->
set_params_data
(
stmt
,
&
expanded_query
))
goto
set_params_data_err
;
#endif
thd
->
stmt_backup
.
set_statement
(
thd
);
thd
->
set_statement
(
stmt
);
thd
->
set_n_backup_statement
(
stmt
,
&
stmt_backup
);
thd
->
current_arena
=
stmt
;
reinit_stmt_before_use
(
thd
,
stmt
->
lex
);
/* From now cursors assume that thd->mem_root is clean */
...
...
@@ -2064,7 +2065,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
reset_stmt_params
(
stmt
);
}
thd
->
set_statement
(
&
thd
->
stmt_backup
);
thd
->
set_statement
(
&
stmt_backup
);
thd
->
current_arena
=
thd
;
DBUG_VOID_RETURN
;
...
...
@@ -2089,6 +2090,7 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name)
binary log.
*/
String
expanded_query
;
Statement
stmt_backup
;
DBUG_ENTER
(
"mysql_sql_stmt_execute"
);
DBUG_ASSERT
(
thd
->
free_list
==
NULL
);
...
...
@@ -2110,16 +2112,16 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name)
/* Must go before setting variables, as it clears thd->user_var_events */
mysql_reset_thd_for_next_command
(
thd
);
thd
->
set_n_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
set_statement
(
stmt
);
thd
->
set_n_backup_statement
(
stmt
,
&
stmt_backup
);
if
(
stmt
->
set_params_from_vars
(
stmt
,
thd
->
stmt_backup
.
lex
->
prepared_stmt_params
,
stmt_backup
.
lex
->
prepared_stmt_params
,
&
expanded_query
))
{
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"EXECUTE"
);
}
thd
->
command
=
COM_STMT_EXECUTE
;
/* For nice messages in general log */
execute_stmt
(
thd
,
stmt
,
&
expanded_query
);
thd
->
set_statement
(
&
stmt_backup
);
DBUG_VOID_RETURN
;
}
...
...
@@ -2176,7 +2178,6 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
close_thread_tables
(
thd
);
// to close derived tables
cleanup_stmt_and_thd_after_use
(
stmt
,
thd
);
reset_stmt_params
(
stmt
);
thd
->
set_statement
(
&
thd
->
stmt_backup
);
thd
->
current_arena
=
thd
;
if
(
stmt
->
state
==
Query_arena
::
PREPARED
)
...
...
@@ -2201,6 +2202,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
ulong
stmt_id
=
uint4korr
(
packet
);
ulong
num_rows
=
uint4korr
(
packet
+
4
);
Prepared_statement
*
stmt
;
Statement
stmt_backup
;
DBUG_ENTER
(
"mysql_stmt_fetch"
);
statistic_increment
(
thd
->
status_var
.
com_stmt_fetch
,
&
LOCK_status
);
...
...
@@ -2214,7 +2216,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
}
thd
->
current_arena
=
stmt
;
thd
->
set_n_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
set_n_backup_statement
(
stmt
,
&
stmt_backup
);
if
(
!
(
specialflag
&
SPECIAL_NO_PRIOR
))
my_pthread_setprio
(
pthread_self
(),
QUERY_PRIOR
);
...
...
@@ -2226,7 +2228,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
if
(
!
(
specialflag
&
SPECIAL_NO_PRIOR
))
my_pthread_setprio
(
pthread_self
(),
WAIT_PRIOR
);
thd
->
restore_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_statement
(
stmt
,
&
stmt_backup
);
thd
->
current_arena
=
thd
;
if
(
!
stmt
->
cursor
->
is_open
())
...
...
@@ -2386,7 +2388,9 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
Prepared_statement
::
Prepared_statement
(
THD
*
thd_arg
)
:
Statement
(
thd_arg
),
:
Statement
(
INITIALIZED
,
++
thd_arg
->
statement_id_counter
,
thd_arg
->
variables
.
query_alloc_block_size
,
thd_arg
->
variables
.
query_prealloc_size
),
thd
(
thd_arg
),
param_array
(
0
),
param_count
(
0
),
...
...
sql/sql_select.cc
View file @
2c14bd9a
...
...
@@ -1824,6 +1824,7 @@ Cursor::fetch(ulong num_rows)
THD
*
thd
=
join
->
thd
;
JOIN_TAB
*
join_tab
=
join
->
join_tab
+
join
->
const_tables
;
enum_nested_loop_state
error
=
NESTED_LOOP_OK
;
Query_arena
backup_arena
;
DBUG_ENTER
(
"Cursor::fetch"
);
DBUG_PRINT
(
"enter"
,(
"rows: %lu"
,
num_rows
));
...
...
@@ -1835,7 +1836,7 @@ Cursor::fetch(ulong num_rows)
thd
->
lock
=
lock
;
thd
->
query_id
=
query_id
;
/* save references to memory, allocated during fetch */
thd
->
set_n_backup_item_arena
(
this
,
&
thd
->
stmt_backup
);
thd
->
set_n_backup_item_arena
(
this
,
&
backup_arena
);
join
->
fetch_limit
+=
num_rows
;
...
...
@@ -1851,7 +1852,7 @@ Cursor::fetch(ulong num_rows)
ha_release_temporary_latches
(
thd
);
#endif
thd
->
restore_backup_item_arena
(
this
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_item_arena
(
this
,
&
backup_arena
);
DBUG_ASSERT
(
thd
->
free_list
==
0
);
reset_thd
(
thd
);
...
...
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