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
7e09f1db
Commit
7e09f1db
authored
Jan 30, 2003
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 'n' concurrent prepared executions
parent
b312b97a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
21 deletions
+48
-21
libmysql/errmsg.c
libmysql/errmsg.c
+3
-3
libmysql/libmysql.c
libmysql/libmysql.c
+35
-5
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+9
-13
No files found.
libmysql/errmsg.c
View file @
7e09f1db
...
...
@@ -59,7 +59,7 @@ const char *client_errors[]=
"No parameters exists in the statement"
,
"Invalid parameter number"
,
"Can't send long data for non string or binary data types (parameter: %d)"
,
"Using un supported
parameter type: %d (parameter: %d)"
"Using un supported
buffer type: %d (parameter: %d)"
,
"Shared memory (%lu)"
,
"Can't open shared memory. Request event don't create (%lu)"
,
"Can't open shared memory. Answer event don't create (%lu)"
,
...
...
@@ -114,7 +114,7 @@ const char *client_errors[]=
"No parameters exists in the statement"
,
"Invalid parameter number"
,
"Can't send long data for non string or binary data types (parameter: %d)"
,
"Using un supported
parameter type: %d (parameter: %d)"
"Using un supported
buffer type: %d (parameter: %d)"
,
"Shared memory (%lu)"
,
"Can't open shared memory. Request event don't create (%lu)"
,
"Can't open shared memory. Answer event don't create (%lu)"
,
...
...
@@ -167,7 +167,7 @@ const char *client_errors[]=
"No parameters exists in the statement"
,
"Invalid parameter number"
,
"Can't send long data for non string or binary data types (parameter: %d)"
,
"Using un supported
parameter type: %d (parameter: %d)"
"Using un supported
buffer type: %d (parameter: %d)"
,
"Shared memory (%lu)"
,
"Can't open shared memory. Request event don't create (%lu)"
,
"Can't open shared memory. Answer event don't create (%lu)"
,
...
...
libmysql/libmysql.c
View file @
7e09f1db
...
...
@@ -3925,6 +3925,28 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
DBUG_RETURN
(
stmt
);
}
/*
Get the execute query meta information for non-select
statements (on demand).
*/
unsigned
int
alloc_stmt_fields
(
MYSQL_STMT
*
stmt
)
{
MYSQL_FIELD
*
fields
;
if
(
!
stmt
->
mysql
->
field_count
)
return
0
;
stmt
->
field_count
=
stmt
->
mysql
->
field_count
;
fields
=
stmt
->
mysql
->
fields
;
if
(
!
(
stmt
->
fields
=
(
MYSQL_FIELD
*
)
alloc_root
(
&
stmt
->
mem_root
,
sizeof
(
fields
)))
||
!
(
stmt
->
bind
=
(
MYSQL_BIND
*
)
alloc_root
(
&
stmt
->
mem_root
,
sizeof
(
MYSQL_BIND
)
*
stmt
->
field_count
)))
return
0
;
memcpy
((
char
*
)
stmt
->
fields
,
(
char
*
)
fields
,
sizeof
(
fields
));
return
stmt
->
field_count
;
}
/*
Returns prepared meta information in the form of resultset
...
...
@@ -3938,8 +3960,10 @@ mysql_prepare_result(MYSQL_STMT *stmt)
DBUG_ENTER
(
"mysql_prepare_result"
);
if
(
!
stmt
->
field_count
||
!
stmt
->
fields
)
DBUG_RETURN
(
0
);
{
if
(
!
alloc_stmt_fields
(
stmt
))
DBUG_RETURN
(
0
);
}
if
(
!
(
result
=
(
MYSQL_RES
*
)
my_malloc
(
sizeof
(
*
result
)
+
sizeof
(
ulong
)
*
stmt
->
field_count
,
MYF
(
MY_WME
|
MY_ZEROFILL
))))
...
...
@@ -4436,7 +4460,7 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
default:
sprintf
(
stmt
->
last_error
,
ER
(
stmt
->
last_errno
=
CR_UNSUPPORTED_PARAM_TYPE
),
param
->
buffer_type
,
param
->
param_number
);
param
->
buffer_type
,
count
);
DBUG_RETURN
(
1
);
}
}
...
...
@@ -4984,6 +5008,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
{
MYSQL_BIND
*
param
,
*
end
;
ulong
bind_count
;
uint
param_count
=
0
;
DBUG_ENTER
(
"mysql_bind_result"
);
DBUG_ASSERT
(
stmt
!=
0
);
...
...
@@ -4999,7 +5024,10 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
DBUG_RETURN
(
1
);
}
#endif
bind_count
=
stmt
->
field_count
;
if
(
!
(
bind_count
=
stmt
->
field_count
)
&&
!
(
bind_count
=
alloc_stmt_fields
(
stmt
)))
DBUG_RETURN
(
0
);
memcpy
((
char
*
)
stmt
->
bind
,
(
char
*
)
bind
,
sizeof
(
MYSQL_BIND
)
*
bind_count
);
...
...
@@ -5015,6 +5043,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
if
(
!
param
->
length
)
param
->
length
=
&
param
->
buffer_length
;
param
->
param_number
=
param_count
++
;
/* Setup data copy functions for the different supported types */
switch
(
param
->
buffer_type
)
{
case
MYSQL_TYPE_TINY
:
...
...
@@ -5066,7 +5095,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
default:
sprintf
(
stmt
->
last_error
,
ER
(
stmt
->
last_errno
=
CR_UNSUPPORTED_PARAM_TYPE
),
param
->
buffer_type
,
param
->
param_number
);
param
->
buffer_type
,
param
_count
);
DBUG_RETURN
(
1
);
}
}
...
...
@@ -5303,6 +5332,7 @@ static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
if
(
!
skip_list
)
stmt
->
mysql
->
stmts
=
list_delete
(
stmt
->
mysql
->
stmts
,
&
stmt
->
list
);
stmt
->
mysql
->
status
=
MYSQL_STATUS_READY
;
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
DBUG_RETURN
(
error
);
}
...
...
sql/sql_class.h
View file @
7e09f1db
...
...
@@ -327,6 +327,7 @@ class MYSQL_ERROR: public Sql_alloc
typedef
struct
st_prep_stmt
{
THD
*
thd
;
LEX
lex
;
Item_param
**
param
;
Item
*
free_list
;
MEM_ROOT
mem_root
;
...
...
sql/sql_prepare.cc
View file @
7e09f1db
...
...
@@ -684,6 +684,7 @@ static bool init_param_items(PREP_STMT *stmt)
List
<
Item
>
&
params
=
stmt
->
thd
->
lex
.
param_list
;
Item_param
**
to
;
stmt
->
lex
=
stmt
->
thd
->
lex
;
if
(
!
stmt
->
param_count
)
stmt
->
param
=
(
Item_param
**
)
0
;
else
...
...
@@ -705,7 +706,7 @@ static bool init_param_items(PREP_STMT *stmt)
static
void
init_stmt_execute
(
PREP_STMT
*
stmt
)
{
THD
*
thd
=
stmt
->
thd
;
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
thd
->
lex
.
select_lex
.
table_list
.
first
;
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
thd
->
lex
.
select_lex
.
table_list
.
first
;
/*
TODO: When the new table structure is ready, then have a status bit
...
...
@@ -713,7 +714,7 @@ static void init_stmt_execute(PREP_STMT *stmt)
and open the tables back.
*/
if
(
tables
)
tables
->
table
=
0
;
//safety - nasty init
tables
->
table
=
0
;
//safety - nasty init
}
/*
...
...
@@ -796,10 +797,8 @@ void mysql_stmt_execute(THD *thd, char *packet)
DBUG_VOID_RETURN
;
}
if
(
my_pthread_setspecific_ptr
(
THR_THD
,
stmt
->
thd
)
||
my_pthread_setspecific_ptr
(
THR_MALLOC
,
&
stmt
->
thd
->
mem_root
))
DBUG_VOID_RETURN
;
LEX
thd_lex
=
thd
->
lex
;
thd
->
lex
=
stmt
->
lex
;
init_stmt_execute
(
stmt
);
if
(
stmt
->
param_count
&&
setup_params_data
(
stmt
))
...
...
@@ -814,17 +813,14 @@ void mysql_stmt_execute(THD *thd, char *packet)
mysql_delete(), mysql_update() and mysql_select() to not to
have re-check on setup_* and other things ..
*/
THD
*
cur_thd
=
stmt
->
thd
;
cur_thd
->
protocol
=
&
cur_thd
->
protocol_prep
;
// Switch to binary protocol
mysql_execute_command
(
cur_thd
);
cur_thd
->
protocol
=
&
cur_thd
->
protocol_simple
;
// Use normal protocol
thd
->
protocol
=
&
thd
->
protocol_prep
;
// Switch to binary protocol
mysql_execute_command
(
thd
);
thd
->
protocol
=
&
thd
->
protocol_simple
;
// Use normal protocol
if
(
!
(
specialflag
&
SPECIAL_NO_PRIOR
))
my_pthread_setprio
(
pthread_self
(),
WAIT_PRIOR
);
my_pthread_setspecific_ptr
(
THR_THD
,
thd
);
my_pthread_setspecific_ptr
(
THR_MALLOC
,
&
thd
->
mem_root
);
thd
->
lex
=
thd_lex
;
DBUG_VOID_RETURN
;
}
...
...
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