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
8aba6f29
Commit
8aba6f29
authored
Jun 08, 2005
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trim trailing spaces.
parent
60a5939f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
104 deletions
+104
-104
sql/sql_prepare.cc
sql/sql_prepare.cc
+104
-104
No files found.
sql/sql_prepare.cc
View file @
8aba6f29
...
@@ -15,18 +15,18 @@
...
@@ -15,18 +15,18 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**********************************************************************
/**********************************************************************
This file contains the implementation of prepare and executes.
This file contains the implementation of prepare and executes.
Prepare:
Prepare:
- Server gets the query from client with command 'COM_PREPARE';
- Server gets the query from client with command 'COM_PREPARE';
in the following format:
in the following format:
[COM_PREPARE:1] [query]
[COM_PREPARE:1] [query]
- Parse the query and recognize any parameter markers '?' and
- Parse the query and recognize any parameter markers '?' and
store its information list in lex->param_list
store its information list in lex->param_list
- Allocate a new statement for this prepare; and keep this in
- Allocate a new statement for this prepare; and keep this in
'thd->prepared_statements' pool.
'thd->prepared_statements' pool.
- Without executing the query, return back to client the total
- Without executing the query, return back to client the total
number of parameters along with result-set metadata information
number of parameters along with result-set metadata information
(if any) in the following format:
(if any) in the following format:
[STMT_ID:4]
[STMT_ID:4]
...
@@ -34,10 +34,10 @@ Prepare:
...
@@ -34,10 +34,10 @@ Prepare:
[Param_count:2]
[Param_count:2]
[Columns meta info] (if Column_count > 0)
[Columns meta info] (if Column_count > 0)
[Params meta info] (if Param_count > 0 ) (TODO : 4.1.1)
[Params meta info] (if Param_count > 0 ) (TODO : 4.1.1)
Prepare-execute:
Prepare-execute:
- Server gets the command 'COM_EXECUTE' to execute the
- Server gets the command 'COM_EXECUTE' to execute the
previously prepared query. If there is any param markers; then client
previously prepared query. If there is any param markers; then client
will send the data in the following format:
will send the data in the following format:
[COM_EXECUTE:1]
[COM_EXECUTE:1]
...
@@ -45,12 +45,12 @@ Prepare-execute:
...
@@ -45,12 +45,12 @@ Prepare-execute:
[NULL_BITS:(param_count+7)/8)]
[NULL_BITS:(param_count+7)/8)]
[TYPES_SUPPLIED_BY_CLIENT(0/1):1]
[TYPES_SUPPLIED_BY_CLIENT(0/1):1]
[[length]data]
[[length]data]
[[length]data] .. [[length]data].
[[length]data] .. [[length]data].
(Note: Except for string/binary types; all other types will not be
(Note: Except for string/binary types; all other types will not be
supplied with length field)
supplied with length field)
- Replace the param items with this new data. If it is a first execute
- Replace the param items with this new data. If it is a first execute
or types altered by client; then setup the conversion routines.
or types altered by client; then setup the conversion routines.
- Execute the query without re-parsing and send back the results
- Execute the query without re-parsing and send back the results
to client
to client
Long data handling:
Long data handling:
...
@@ -61,8 +61,8 @@ Long data handling:
...
@@ -61,8 +61,8 @@ Long data handling:
- data from the packet is appended to long data value buffer for this
- data from the packet is appended to long data value buffer for this
placeholder.
placeholder.
- It's up to the client to check for read data ended. The server doesn't
- It's up to the client to check for read data ended. The server doesn't
care; and also server doesn't notify to the client that it got the
care; and also server doesn't notify to the client that it got the
data or not; if there is any error; then during execute; the error
data or not; if there is any error; then during execute; the error
will be returned
will be returned
***********************************************************************/
***********************************************************************/
...
@@ -97,7 +97,7 @@ public:
...
@@ -97,7 +97,7 @@ public:
#else
#else
bool
(
*
set_params_data
)(
Prepared_statement
*
st
,
String
*
expanded_query
);
bool
(
*
set_params_data
)(
Prepared_statement
*
st
,
String
*
expanded_query
);
#endif
#endif
bool
(
*
set_params_from_vars
)(
Prepared_statement
*
stmt
,
bool
(
*
set_params_from_vars
)(
Prepared_statement
*
stmt
,
List
<
LEX_STRING
>&
varnames
,
List
<
LEX_STRING
>&
varnames
,
String
*
expanded_query
);
String
*
expanded_query
);
public:
public:
...
@@ -167,7 +167,7 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
...
@@ -167,7 +167,7 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
Send types and names of placeholders to the client
Send types and names of placeholders to the client
XXX: fix this nasty upcast from List<Item_param> to List<Item>
XXX: fix this nasty upcast from List<Item_param> to List<Item>
*/
*/
DBUG_RETURN
(
my_net_write
(
net
,
buff
,
sizeof
(
buff
))
||
DBUG_RETURN
(
my_net_write
(
net
,
buff
,
sizeof
(
buff
))
||
(
stmt
->
param_count
&&
(
stmt
->
param_count
&&
stmt
->
thd
->
protocol_simple
.
send_fields
((
List
<
Item
>
*
)
stmt
->
thd
->
protocol_simple
.
send_fields
((
List
<
Item
>
*
)
&
stmt
->
lex
->
param_list
,
&
stmt
->
lex
->
param_list
,
...
@@ -220,7 +220,7 @@ static ulong get_param_length(uchar **packet, ulong len)
...
@@ -220,7 +220,7 @@ static ulong get_param_length(uchar **packet, ulong len)
}
}
if
(
len
<
5
)
if
(
len
<
5
)
return
0
;
return
0
;
(
*
packet
)
+=
9
;
// Must be 254 when here
(
*
packet
)
+=
9
;
// Must be 254 when here
/*
/*
In our client-server protocol all numbers bigger than 2^24
In our client-server protocol all numbers bigger than 2^24
stored as 8 bytes with uint8korr. Here we always know that
stored as 8 bytes with uint8korr. Here we always know that
...
@@ -242,7 +242,7 @@ static ulong get_param_length(uchar **packet, ulong len)
...
@@ -242,7 +242,7 @@ static ulong get_param_length(uchar **packet, ulong len)
pos input data buffer
pos input data buffer
len length of data in the buffer
len length of data in the buffer
All these functions read the data from pos, convert it to requested type
All these functions read the data from pos, convert it to requested type
and assign to param; pos is advanced to predefined length.
and assign to param; pos is advanced to predefined length.
Make a note that the NULL handling is examined at first execution
Make a note that the NULL handling is examined at first execution
...
@@ -260,7 +260,7 @@ static void set_param_tiny(Item_param *param, uchar **pos, ulong len)
...
@@ -260,7 +260,7 @@ static void set_param_tiny(Item_param *param, uchar **pos, ulong len)
return
;
return
;
#endif
#endif
int8
value
=
(
int8
)
**
pos
;
int8
value
=
(
int8
)
**
pos
;
param
->
set_int
(
param
->
unsigned_flag
?
(
longlong
)
((
uint8
)
value
)
:
param
->
set_int
(
param
->
unsigned_flag
?
(
longlong
)
((
uint8
)
value
)
:
(
longlong
)
value
,
4
);
(
longlong
)
value
,
4
);
*
pos
+=
1
;
*
pos
+=
1
;
}
}
...
@@ -480,7 +480,7 @@ static void set_param_str(Item_param *param, uchar **pos, ulong len)
...
@@ -480,7 +480,7 @@ static void set_param_str(Item_param *param, uchar **pos, ulong len)
}
}
#undef get_param_length
#undef get_param_length
static
void
setup_one_conversion_function
(
THD
*
thd
,
Item_param
*
param
,
static
void
setup_one_conversion_function
(
THD
*
thd
,
Item_param
*
param
,
uchar
param_type
)
uchar
param_type
)
...
@@ -583,12 +583,12 @@ static void setup_one_conversion_function(THD *thd, Item_param *param,
...
@@ -583,12 +583,12 @@ static void setup_one_conversion_function(THD *thd, Item_param *param,
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
/*
/*
Update the parameter markers by reading data from client packet
Update the parameter markers by reading data from client packet
and if binary/update log is set, generate the valid query.
and if binary/update log is set, generate the valid query.
*/
*/
static
bool
insert_params_withlog
(
Prepared_statement
*
stmt
,
uchar
*
null_array
,
static
bool
insert_params_withlog
(
Prepared_statement
*
stmt
,
uchar
*
null_array
,
uchar
*
read_pos
,
uchar
*
data_end
,
uchar
*
read_pos
,
uchar
*
data_end
,
String
*
query
)
String
*
query
)
{
{
THD
*
thd
=
stmt
->
thd
;
THD
*
thd
=
stmt
->
thd
;
...
@@ -596,14 +596,14 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array,
...
@@ -596,14 +596,14 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array,
Item_param
**
end
=
begin
+
stmt
->
param_count
;
Item_param
**
end
=
begin
+
stmt
->
param_count
;
uint32
length
=
0
;
uint32
length
=
0
;
String
str
;
String
str
;
const
String
*
res
;
const
String
*
res
;
DBUG_ENTER
(
"insert_params_withlog"
);
DBUG_ENTER
(
"insert_params_withlog"
);
if
(
query
->
copy
(
stmt
->
query
,
stmt
->
query_length
,
default_charset_info
))
if
(
query
->
copy
(
stmt
->
query
,
stmt
->
query_length
,
default_charset_info
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
for
(
Item_param
**
it
=
begin
;
it
<
end
;
++
it
)
for
(
Item_param
**
it
=
begin
;
it
<
end
;
++
it
)
{
{
Item_param
*
param
=
*
it
;
Item_param
*
param
=
*
it
;
...
@@ -624,7 +624,7 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array,
...
@@ -624,7 +624,7 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array,
if
(
query
->
replace
(
param
->
pos_in_query
+
length
,
1
,
*
res
))
if
(
query
->
replace
(
param
->
pos_in_query
+
length
,
1
,
*
res
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
length
+=
res
->
length
()
-
1
;
length
+=
res
->
length
()
-
1
;
}
}
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -632,13 +632,13 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array,
...
@@ -632,13 +632,13 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array,
static
bool
insert_params
(
Prepared_statement
*
stmt
,
uchar
*
null_array
,
static
bool
insert_params
(
Prepared_statement
*
stmt
,
uchar
*
null_array
,
uchar
*
read_pos
,
uchar
*
data_end
,
uchar
*
read_pos
,
uchar
*
data_end
,
String
*
expanded_query
)
String
*
expanded_query
)
{
{
Item_param
**
begin
=
stmt
->
param_array
;
Item_param
**
begin
=
stmt
->
param_array
;
Item_param
**
end
=
begin
+
stmt
->
param_count
;
Item_param
**
end
=
begin
+
stmt
->
param_count
;
DBUG_ENTER
(
"insert_params"
);
DBUG_ENTER
(
"insert_params"
);
for
(
Item_param
**
it
=
begin
;
it
<
end
;
++
it
)
for
(
Item_param
**
it
=
begin
;
it
<
end
;
++
it
)
{
{
...
@@ -672,7 +672,7 @@ static bool setup_conversion_functions(Prepared_statement *stmt,
...
@@ -672,7 +672,7 @@ static bool setup_conversion_functions(Prepared_statement *stmt,
if
(
*
read_pos
++
)
//types supplied / first execute
if
(
*
read_pos
++
)
//types supplied / first execute
{
{
/*
/*
First execute or types altered by the client, setup the
First execute or types altered by the client, setup the
conversion routines for all parameters (one time)
conversion routines for all parameters (one time)
*/
*/
Item_param
**
it
=
stmt
->
param_array
;
Item_param
**
it
=
stmt
->
param_array
;
...
@@ -720,8 +720,8 @@ static bool emb_insert_params(Prepared_statement *stmt, String *expanded_query)
...
@@ -720,8 +720,8 @@ static bool emb_insert_params(Prepared_statement *stmt, String *expanded_query)
uchar
*
buff
=
(
uchar
*
)
client_param
->
buffer
;
uchar
*
buff
=
(
uchar
*
)
client_param
->
buffer
;
param
->
unsigned_flag
=
client_param
->
is_unsigned
;
param
->
unsigned_flag
=
client_param
->
is_unsigned
;
param
->
set_param_func
(
param
,
&
buff
,
param
->
set_param_func
(
param
,
&
buff
,
client_param
->
length
?
client_param
->
length
?
*
client_param
->
length
:
*
client_param
->
length
:
client_param
->
buffer_length
);
client_param
->
buffer_length
);
}
}
}
}
...
@@ -747,7 +747,7 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query)
...
@@ -747,7 +747,7 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query)
if
(
query
->
copy
(
stmt
->
query
,
stmt
->
query_length
,
default_charset_info
))
if
(
query
->
copy
(
stmt
->
query
,
stmt
->
query_length
,
default_charset_info
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
for
(;
it
<
end
;
++
it
,
++
client_param
)
for
(;
it
<
end
;
++
it
,
++
client_param
)
{
{
Item_param
*
param
=
*
it
;
Item_param
*
param
=
*
it
;
...
@@ -759,10 +759,10 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query)
...
@@ -759,10 +759,10 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query)
else
else
{
{
uchar
*
buff
=
(
uchar
*
)
client_param
->
buffer
;
uchar
*
buff
=
(
uchar
*
)
client_param
->
buffer
;
param
->
unsigned_flag
=
client_param
->
is_unsigned
;
param
->
unsigned_flag
=
client_param
->
is_unsigned
;
param
->
set_param_func
(
param
,
&
buff
,
param
->
set_param_func
(
param
,
&
buff
,
client_param
->
length
?
client_param
->
length
?
*
client_param
->
length
:
*
client_param
->
length
:
client_param
->
buffer_length
);
client_param
->
buffer_length
);
}
}
}
}
...
@@ -881,12 +881,12 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt,
...
@@ -881,12 +881,12 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt,
}
}
/*
/*
Validate INSERT statement:
Validate INSERT statement:
SYNOPSIS
SYNOPSIS
mysql_test_insert()
mysql_test_insert()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
global/local table list
tables
global/local table list
RETURN VALUE
RETURN VALUE
FALSE success
FALSE success
...
@@ -895,7 +895,7 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt,
...
@@ -895,7 +895,7 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt,
static
bool
mysql_test_insert
(
Prepared_statement
*
stmt
,
static
bool
mysql_test_insert
(
Prepared_statement
*
stmt
,
TABLE_LIST
*
table_list
,
TABLE_LIST
*
table_list
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
fields
,
List
<
List_item
>
&
values_list
,
List
<
List_item
>
&
values_list
,
List
<
Item
>
&
update_fields
,
List
<
Item
>
&
update_fields
,
List
<
Item
>
&
update_values
,
List
<
Item
>
&
update_values
,
...
@@ -958,7 +958,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
...
@@ -958,7 +958,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
goto
error
;
goto
error
;
}
}
if
(
setup_fields
(
thd
,
0
,
table_list
,
*
values
,
0
,
0
,
0
))
if
(
setup_fields
(
thd
,
0
,
table_list
,
*
values
,
0
,
0
,
0
))
goto
error
;
goto
error
;
}
}
}
}
DBUG_RETURN
(
FALSE
);
DBUG_RETURN
(
FALSE
);
...
@@ -974,8 +974,8 @@ error:
...
@@ -974,8 +974,8 @@ error:
SYNOPSIS
SYNOPSIS
mysql_test_update()
mysql_test_update()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
RETURN VALUE
RETURN VALUE
0 success
0 success
...
@@ -991,7 +991,7 @@ static int mysql_test_update(Prepared_statement *stmt,
...
@@ -991,7 +991,7 @@ static int mysql_test_update(Prepared_statement *stmt,
uint
table_count
=
0
;
uint
table_count
=
0
;
SELECT_LEX
*
select
=
&
stmt
->
lex
->
select_lex
;
SELECT_LEX
*
select
=
&
stmt
->
lex
->
select_lex
;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint
want_privilege
;
uint
want_privilege
;
#endif
#endif
DBUG_ENTER
(
"mysql_test_update"
);
DBUG_ENTER
(
"mysql_test_update"
);
...
@@ -1046,7 +1046,7 @@ static int mysql_test_update(Prepared_statement *stmt,
...
@@ -1046,7 +1046,7 @@ static int mysql_test_update(Prepared_statement *stmt,
#endif
#endif
if
(
setup_fields
(
thd
,
0
,
table_list
,
stmt
->
lex
->
value_list
,
0
,
0
,
0
))
if
(
setup_fields
(
thd
,
0
,
table_list
,
stmt
->
lex
->
value_list
,
0
,
0
,
0
))
goto
error
;
goto
error
;
/* TODO: here we should send types of placeholders to the client. */
/* TODO: here we should send types of placeholders to the client. */
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
error:
error:
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
@@ -1058,8 +1058,8 @@ error:
...
@@ -1058,8 +1058,8 @@ error:
SYNOPSIS
SYNOPSIS
mysql_test_delete()
mysql_test_delete()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
RETURN VALUE
RETURN VALUE
FALSE success
FALSE success
...
@@ -1093,12 +1093,12 @@ error:
...
@@ -1093,12 +1093,12 @@ error:
/*
/*
Validate SELECT statement.
Validate SELECT statement.
In case of success, if this query is not EXPLAIN, send column list info
In case of success, if this query is not EXPLAIN, send column list info
back to client.
back to client.
SYNOPSIS
SYNOPSIS
mysql_test_select()
mysql_test_select()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
RETURN VALUE
RETURN VALUE
FALSE success
FALSE success
...
@@ -1180,9 +1180,9 @@ error:
...
@@ -1180,9 +1180,9 @@ error:
SYNOPSIS
SYNOPSIS
mysql_test_do_fields()
mysql_test_do_fields()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
values
list of expressions
values
list of expressions
RETURN VALUE
RETURN VALUE
FALSE success
FALSE success
...
@@ -1190,8 +1190,8 @@ error:
...
@@ -1190,8 +1190,8 @@ error:
*/
*/
static
bool
mysql_test_do_fields
(
Prepared_statement
*
stmt
,
static
bool
mysql_test_do_fields
(
Prepared_statement
*
stmt
,
TABLE_LIST
*
tables
,
TABLE_LIST
*
tables
,
List
<
Item
>
*
values
)
List
<
Item
>
*
values
)
{
{
THD
*
thd
=
stmt
->
thd
;
THD
*
thd
=
stmt
->
thd
;
...
@@ -1210,9 +1210,9 @@ static bool mysql_test_do_fields(Prepared_statement *stmt,
...
@@ -1210,9 +1210,9 @@ static bool mysql_test_do_fields(Prepared_statement *stmt,
SYNOPSIS
SYNOPSIS
mysql_test_set_fields()
mysql_test_set_fields()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
values
list of expressions
values
list of expressions
RETURN VALUE
RETURN VALUE
FALSE success
FALSE success
...
@@ -1323,8 +1323,8 @@ select_like_stmt_test_with_open_n_lock(Prepared_statement *stmt,
...
@@ -1323,8 +1323,8 @@ select_like_stmt_test_with_open_n_lock(Prepared_statement *stmt,
SYNOPSIS
SYNOPSIS
mysql_test_create_table()
mysql_test_create_table()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
RETURN VALUE
RETURN VALUE
FALSE success
FALSE success
...
@@ -1364,8 +1364,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
...
@@ -1364,8 +1364,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
SYNOPSIS
SYNOPSIS
mysql_test_multiupdate()
mysql_test_multiupdate()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
converted converted to multi-update from usual update
converted converted to multi-update from usual update
RETURN VALUE
RETURN VALUE
...
@@ -1374,7 +1374,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
...
@@ -1374,7 +1374,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
*/
*/
static
bool
mysql_test_multiupdate
(
Prepared_statement
*
stmt
,
static
bool
mysql_test_multiupdate
(
Prepared_statement
*
stmt
,
TABLE_LIST
*
tables
,
TABLE_LIST
*
tables
,
bool
converted
)
bool
converted
)
{
{
/* if we switched from normal update, rights are checked */
/* if we switched from normal update, rights are checked */
...
@@ -1391,8 +1391,8 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
...
@@ -1391,8 +1391,8 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
SYNOPSIS
SYNOPSIS
mysql_test_multidelete()
mysql_test_multidelete()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables queries
tables
list of tables queries
RETURN VALUE
RETURN VALUE
0 success
0 success
...
@@ -1400,7 +1400,7 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
...
@@ -1400,7 +1400,7 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
*/
*/
static
bool
mysql_test_multidelete
(
Prepared_statement
*
stmt
,
static
bool
mysql_test_multidelete
(
Prepared_statement
*
stmt
,
TABLE_LIST
*
tables
)
TABLE_LIST
*
tables
)
{
{
uint
fake_counter
;
uint
fake_counter
;
...
@@ -1419,7 +1419,7 @@ static bool mysql_test_multidelete(Prepared_statement *stmt,
...
@@ -1419,7 +1419,7 @@ static bool mysql_test_multidelete(Prepared_statement *stmt,
if
(
!
tables
->
table
)
if
(
!
tables
->
table
)
{
{
my_error
(
ER_VIEW_DELETE_MERGE_VIEW
,
MYF
(
0
),
my_error
(
ER_VIEW_DELETE_MERGE_VIEW
,
MYF
(
0
),
tables
->
view_db
.
str
,
tables
->
view_name
.
str
);
tables
->
view_db
.
str
,
tables
->
view_name
.
str
);
goto
error
;
goto
error
;
}
}
return
FALSE
;
return
FALSE
;
...
@@ -1460,8 +1460,8 @@ static bool mysql_insert_select_prepare_tester(THD *thd)
...
@@ -1460,8 +1460,8 @@ static bool mysql_insert_select_prepare_tester(THD *thd)
SYNOPSIS
SYNOPSIS
mysql_test_insert_select()
mysql_test_insert_select()
stmt
prepared statemen handler
stmt
prepared statemen handler
tables
list of tables of query
tables
list of tables of query
RETURN VALUE
RETURN VALUE
0 success
0 success
...
@@ -1470,7 +1470,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd)
...
@@ -1470,7 +1470,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd)
*/
*/
static
int
mysql_test_insert_select
(
Prepared_statement
*
stmt
,
static
int
mysql_test_insert_select
(
Prepared_statement
*
stmt
,
TABLE_LIST
*
tables
)
TABLE_LIST
*
tables
)
{
{
int
res
;
int
res
;
LEX
*
lex
=
stmt
->
lex
;
LEX
*
lex
=
stmt
->
lex
;
...
@@ -1538,9 +1538,9 @@ static bool check_prepared_statement(Prepared_statement *stmt,
...
@@ -1538,9 +1538,9 @@ static bool check_prepared_statement(Prepared_statement *stmt,
case
SQLCOM_REPLACE
:
case
SQLCOM_REPLACE
:
case
SQLCOM_INSERT
:
case
SQLCOM_INSERT
:
res
=
mysql_test_insert
(
stmt
,
tables
,
lex
->
field_list
,
res
=
mysql_test_insert
(
stmt
,
tables
,
lex
->
field_list
,
lex
->
many_values
,
lex
->
many_values
,
select_lex
->
item_list
,
lex
->
value_list
,
select_lex
->
item_list
,
lex
->
value_list
,
lex
->
duplicates
);
lex
->
duplicates
);
break
;
break
;
case
SQLCOM_UPDATE
:
case
SQLCOM_UPDATE
:
...
@@ -1566,7 +1566,7 @@ static bool check_prepared_statement(Prepared_statement *stmt,
...
@@ -1566,7 +1566,7 @@ static bool check_prepared_statement(Prepared_statement *stmt,
case
SQLCOM_CREATE_TABLE
:
case
SQLCOM_CREATE_TABLE
:
res
=
mysql_test_create_table
(
stmt
);
res
=
mysql_test_create_table
(
stmt
);
break
;
break
;
case
SQLCOM_DO
:
case
SQLCOM_DO
:
res
=
mysql_test_do_fields
(
stmt
,
tables
,
lex
->
insert_list
);
res
=
mysql_test_do_fields
(
stmt
,
tables
,
lex
->
insert_list
);
break
;
break
;
...
@@ -1661,30 +1661,30 @@ static bool init_param_array(Prepared_statement *stmt)
...
@@ -1661,30 +1661,30 @@ static bool init_param_array(Prepared_statement *stmt)
/*
/*
Given a query string with parameter markers, create a Prepared Statement
Given a query string with parameter markers, create a Prepared Statement
from it and send PS info back to the client.
from it and send PS info back to the client.
SYNOPSIS
SYNOPSIS
mysql_stmt_prepare()
mysql_stmt_prepare()
packet query to be prepared
packet query to be prepared
packet_length query string length, including ignored trailing NULL or
packet_length query string length, including ignored trailing NULL or
quote char.
quote char.
name NULL or statement name. For unnamed statements binary PS
name NULL or statement name. For unnamed statements binary PS
protocol is used, for named statements text protocol is
protocol is used, for named statements text protocol is
used.
used.
RETURN
RETURN
FALSE OK, statement prepared successfully
FALSE OK, statement prepared successfully
TRUE Error
TRUE Error
NOTES
NOTES
This function parses the query and sends the total number of parameters
This function parses the query and sends the total number of parameters
and resultset metadata information back to client (if any), without
and resultset metadata information back to client (if any), without
executing the query i.e. without any log/disk writes. This allows the
executing the query i.e. without any log/disk writes. This allows the
queries to be re-executed without re-parsing during execute.
queries to be re-executed without re-parsing during execute.
If parameter markers are found in the query, then store the information
If parameter markers are found in the query, then store the information
using Item_param along with maintaining a list in lex->param_array, so
using Item_param along with maintaining a list in lex->param_array, so
that a fast and direct retrieval can be made without going through all
that a fast and direct retrieval can be made without going through all
field items.
field items.
*/
*/
bool
mysql_stmt_prepare
(
THD
*
thd
,
char
*
packet
,
uint
packet_length
,
bool
mysql_stmt_prepare
(
THD
*
thd
,
char
*
packet
,
uint
packet_length
,
...
@@ -1857,8 +1857,8 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
...
@@ -1857,8 +1857,8 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
}
}
/*
/*
TODO: When the new table structure is ready, then have a status bit
TODO: When the new table structure is ready, then have a status bit
to indicate the table is altered, and re-do the setup_*
to indicate the table is altered, and re-do the setup_*
and open the tables back.
and open the tables back.
*/
*/
/*
/*
...
@@ -1867,8 +1867,8 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
...
@@ -1867,8 +1867,8 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
they have their own table list).
they have their own table list).
*/
*/
for
(
TABLE_LIST
*
tables
=
lex
->
query_tables
;
for
(
TABLE_LIST
*
tables
=
lex
->
query_tables
;
tables
;
tables
;
tables
=
tables
->
next_global
)
tables
=
tables
->
next_global
)
{
{
/*
/*
Reset old pointers to TABLEs: they are not valid since the tables
Reset old pointers to TABLEs: they are not valid since the tables
...
@@ -1899,10 +1899,10 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
...
@@ -1899,10 +1899,10 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
/*
/*
Clears parameters from data left from previous execution or long data
Clears parameters from data left from previous execution or long data
SYNOPSIS
SYNOPSIS
reset_stmt_params()
reset_stmt_params()
stmt
prepared statement for which parameters should be reset
stmt
prepared statement for which parameters should be reset
*/
*/
static
void
reset_stmt_params
(
Prepared_statement
*
stmt
)
static
void
reset_stmt_params
(
Prepared_statement
*
stmt
)
...
@@ -1999,8 +1999,8 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
...
@@ -1999,8 +1999,8 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
}
}
#else
#else
/*
/*
In embedded library we re-install conversion routines each time
In embedded library we re-install conversion routines each time
we set params, and also we don't need to parse packet.
we set params, and also we don't need to parse packet.
So we do it in one function.
So we do it in one function.
*/
*/
if
(
stmt
->
param_count
&&
stmt
->
set_params_data
(
stmt
,
&
expanded_query
))
if
(
stmt
->
param_count
&&
stmt
->
set_params_data
(
stmt
,
&
expanded_query
))
...
@@ -2163,9 +2163,9 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
...
@@ -2163,9 +2163,9 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
SYNOPSIS
SYNOPSIS
mysql_stmt_fetch()
mysql_stmt_fetch()
thd
Thread handler
thd
Thread handler
packet
Packet from client (with stmt_id & num_rows)
packet
Packet from client (with stmt_id & num_rows)
packet_length
Length of packet
packet_length
Length of packet
*/
*/
void
mysql_stmt_fetch
(
THD
*
thd
,
char
*
packet
,
uint
packet_length
)
void
mysql_stmt_fetch
(
THD
*
thd
,
char
*
packet
,
uint
packet_length
)
...
@@ -2192,7 +2192,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
...
@@ -2192,7 +2192,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
if
(
!
(
specialflag
&
SPECIAL_NO_PRIOR
))
if
(
!
(
specialflag
&
SPECIAL_NO_PRIOR
))
my_pthread_setprio
(
pthread_self
(),
QUERY_PRIOR
);
my_pthread_setprio
(
pthread_self
(),
QUERY_PRIOR
);
thd
->
protocol
=
&
thd
->
protocol_prep
;
// Switch to binary protocol
thd
->
protocol
=
&
thd
->
protocol_prep
;
// Switch to binary protocol
stmt
->
cursor
->
fetch
(
num_rows
);
stmt
->
cursor
->
fetch
(
num_rows
);
thd
->
protocol
=
&
thd
->
protocol_simple
;
// Use normal protocol
thd
->
protocol
=
&
thd
->
protocol_simple
;
// Use normal protocol
...
@@ -2213,7 +2213,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
...
@@ -2213,7 +2213,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
SYNOPSIS
SYNOPSIS
mysql_stmt_reset()
mysql_stmt_reset()
thd Thread handle
thd Thread handle
packet
Packet with stmt id
packet
Packet with stmt id
DESCRIPTION
DESCRIPTION
This function resets statement to the state it was right after prepare.
This function resets statement to the state it was right after prepare.
...
@@ -2240,22 +2240,22 @@ void mysql_stmt_reset(THD *thd, char *packet)
...
@@ -2240,22 +2240,22 @@ void mysql_stmt_reset(THD *thd, char *packet)
stmt
->
state
=
Item_arena
::
PREPARED
;
stmt
->
state
=
Item_arena
::
PREPARED
;
/*
/*
Clear parameters from data which could be set by
Clear parameters from data which could be set by
mysql_stmt_send_long_data() call.
mysql_stmt_send_long_data() call.
*/
*/
reset_stmt_params
(
stmt
);
reset_stmt_params
(
stmt
);
mysql_reset_thd_for_next_command
(
thd
);
mysql_reset_thd_for_next_command
(
thd
);
send_ok
(
thd
);
send_ok
(
thd
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
/*
/*
Delete a prepared statement from memory.
Delete a prepared statement from memory.
Note: we don't send any reply to that command.
Note: we don't send any reply to that command.
*/
*/
void
mysql_stmt_free
(
THD
*
thd
,
char
*
packet
)
void
mysql_stmt_free
(
THD
*
thd
,
char
*
packet
)
...
@@ -2280,9 +2280,9 @@ void mysql_stmt_free(THD *thd, char *packet)
...
@@ -2280,9 +2280,9 @@ void mysql_stmt_free(THD *thd, char *packet)
SYNOPSIS
SYNOPSIS
mysql_stmt_get_longdata()
mysql_stmt_get_longdata()
thd
Thread handle
thd
Thread handle
pos
String to append
pos
String to append
packet_length
Length of string
packet_length
Length of string
DESCRIPTION
DESCRIPTION
Get a part of a long data.
Get a part of a long data.
...
@@ -2301,7 +2301,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
...
@@ -2301,7 +2301,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
Prepared_statement
*
stmt
;
Prepared_statement
*
stmt
;
Item_param
*
param
;
Item_param
*
param
;
char
*
packet_end
=
packet
+
packet_length
-
1
;
char
*
packet_end
=
packet
+
packet_length
-
1
;
DBUG_ENTER
(
"mysql_stmt_get_longdata"
);
DBUG_ENTER
(
"mysql_stmt_get_longdata"
);
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
...
...
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