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
3559cf86
Commit
3559cf86
authored
Feb 10, 2004
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/dlenev/src/mysql-4.1-bg2248
parents
dc696d2e
8ec663ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
92 deletions
+79
-92
include/mysql.h
include/mysql.h
+0
-3
libmysql/libmysql.c
libmysql/libmysql.c
+10
-60
tests/client_test.c
tests/client_test.c
+69
-29
No files found.
include/mysql.h
View file @
3559cf86
...
...
@@ -57,9 +57,6 @@ typedef int my_socket;
#include "mysql_com.h"
#include "mysql_version.h"
#include "typelib.h"
#ifndef DBUG_OFF
#define CHECK_EXTRA_ARGUMENTS
#endif
#include "my_list.h"
/* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
...
...
libmysql/libmysql.c
View file @
3559cf86
...
...
@@ -1653,14 +1653,6 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
DBUG_ENTER
(
"mysql_prepare"
);
DBUG_ASSERT
(
mysql
!=
0
);
#ifdef CHECK_EXTRA_ARGUMENTS
if
(
!
query
)
{
set_mysql_error
(
mysql
,
CR_NULL_POINTER
,
unknown_sqlstate
);
DBUG_RETURN
(
0
);
}
#endif
if
(
!
(
stmt
=
(
MYSQL_STMT
*
)
my_malloc
(
sizeof
(
MYSQL_STMT
),
MYF
(
MY_WME
|
MY_ZEROFILL
)))
||
!
(
stmt
->
query
=
my_strdup_with_length
((
byte
*
)
query
,
length
,
MYF
(
0
))))
...
...
@@ -2086,19 +2078,6 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
{
DBUG_ENTER
(
"mysql_execute"
);
if
(
stmt
->
state
==
MY_ST_UNKNOWN
)
{
set_stmt_error
(
stmt
,
CR_NO_PREPARE_STMT
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
#ifdef CHECK_EXTRA_ARGUMENTS
if
(
stmt
->
param_count
&&
!
stmt
->
param_buffers
)
{
/* Parameters exists, but no bound buffers */
set_stmt_error
(
stmt
,
CR_NOT_ALL_PARAMS_BOUND
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
#endif
if
((
*
stmt
->
mysql
->
methods
->
stmt_execute
)(
stmt
))
DBUG_RETURN
(
1
);
...
...
@@ -2144,19 +2123,6 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
MYSQL_BIND
*
param
,
*
end
;
DBUG_ENTER
(
"mysql_bind_param"
);
#ifdef CHECK_EXTRA_ARGUMENTS
if
(
stmt
->
state
==
MY_ST_UNKNOWN
)
{
set_stmt_error
(
stmt
,
CR_NO_PREPARE_STMT
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
if
(
!
stmt
->
param_count
)
{
set_stmt_error
(
stmt
,
CR_NO_PARAMETERS_EXISTS
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
#endif
/* Allocated on prepare */
memcpy
((
char
*
)
stmt
->
params
,
(
char
*
)
bind
,
sizeof
(
MYSQL_BIND
)
*
stmt
->
param_count
);
...
...
@@ -2279,11 +2245,6 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number,
DBUG_PRINT
(
"enter"
,(
"param no : %d, data : %lx, length : %ld"
,
param_number
,
data
,
length
));
if
(
param_number
>=
stmt
->
param_count
)
{
set_stmt_error
(
stmt
,
CR_INVALID_PARAMETER_NO
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
param
=
stmt
->
params
+
param_number
;
if
(
param
->
buffer_type
<
MYSQL_TYPE_TINY_BLOB
||
param
->
buffer_type
>
MYSQL_TYPE_STRING
)
...
...
@@ -2853,18 +2814,6 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
DBUG_ENTER
(
"mysql_bind_result"
);
DBUG_ASSERT
(
stmt
!=
0
);
#ifdef CHECK_EXTRA_ARGUMENTS
if
(
stmt
->
state
==
MY_ST_UNKNOWN
)
{
set_stmt_error
(
stmt
,
CR_NO_PREPARE_STMT
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
if
(
!
bind
)
{
set_stmt_error
(
stmt
,
CR_NULL_POINTER
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
#endif
if
(
!
(
bind_count
=
stmt
->
field_count
)
&&
!
(
bind_count
=
alloc_stmt_fields
(
stmt
)))
DBUG_RETURN
(
0
);
...
...
@@ -3035,6 +2984,15 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
}
else
/* un-buffered */
{
if
(
mysql
->
status
!=
MYSQL_STATUS_GET_RESULT
)
{
if
(
!
stmt
->
field_count
)
goto
no_data
;
set_stmt_error
(
stmt
,
CR_COMMANDS_OUT_OF_SYNC
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
if
((
*
mysql
->
methods
->
unbuffered_fetch
)(
mysql
,
(
char
**
)
&
row
))
{
set_stmt_errmsg
(
stmt
,
mysql
->
net
.
last_error
,
mysql
->
net
.
last_errno
,
...
...
@@ -3065,7 +3023,7 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
mysql_fetch_column()
stmt Prepared statement handler
bind Where data should be placed. Should be filled in as
when calling mysql_bind_
param
()
when calling mysql_bind_
result
()
column Column to fetch (first column is 0)
ulong offset Offset in result data (to fetch blob in pieces)
This is normally 0
...
...
@@ -3083,14 +3041,6 @@ int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
if
(
!
stmt
->
current_row
)
goto
no_data
;
#ifdef CHECK_EXTRA_ARGUMENTS
if
(
column
>=
stmt
->
field_count
)
{
set_stmt_errmsg
(
stmt
,
"Invalid column descriptor"
,
1
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
}
#endif
if
(
param
->
null_field
)
{
if
(
bind
->
is_null
)
...
...
tests/client_test.c
View file @
3559cf86
...
...
@@ -953,8 +953,6 @@ static void test_prepare_simple()
verify_param_count
(
stmt
,
1
);
rc
=
mysql_execute
(
stmt
);
mystmt_r
(
stmt
,
rc
);
mysql_stmt_close
(
stmt
);
/* select */
...
...
@@ -5589,27 +5587,24 @@ static void test_pure_coverage()
stmt
=
mysql_prepare
(
mysql
,
"insert into test_pure(c67788) values(10)"
,
100
);
mystmt_init_r
(
stmt
);
#ifndef DBUG_OFF
stmt
=
mysql_prepare
(
mysql
,(
const
char
*
)
0
,
0
);
mystmt_init_r
(
stmt
);
/* Query without params and result should allow to bind 0 arrays */
stmt
=
mysql_prepare
(
mysql
,
"insert into test_pure(c2) values(10)"
,
100
);
mystmt_init
(
stmt
);
rc
=
mysql_bind_param
(
stmt
,
(
MYSQL_BIND
*
)
0
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_bind_
param
(
stmt
,
bind
);
mystmt
_r
(
stmt
,
rc
);
rc
=
mysql_bind_
result
(
stmt
,
(
MYSQL_BIND
*
)
0
);
mystmt
(
stmt
,
rc
);
mysql_stmt_close
(
stmt
);
#endif
stmt
=
mysql_prepare
(
mysql
,
"insert into test_pure(c2) values(?)"
,
100
);
mystmt_init
(
stmt
);
#ifndef DBUG_OFF
rc
=
mysql_execute
(
stmt
);
mystmt_r
(
stmt
,
rc
);
/* No parameters supplied */
#endif
bind
[
0
].
length
=
&
length
;
bind
[
0
].
is_null
=
0
;
bind
[
0
].
buffer_length
=
0
;
...
...
@@ -5622,9 +5617,6 @@ static void test_pure_coverage()
rc
=
mysql_bind_param
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_send_long_data
(
stmt
,
20
,
(
char
*
)
"venu"
,
4
);
mystmt_r
(
stmt
,
rc
);
/* wrong param number */
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt
(
stmt
,
rc
);
...
...
@@ -5636,14 +5628,9 @@ static void test_pure_coverage()
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
#ifndef DBUG_OFF
rc
=
mysql_bind_result
(
stmt
,
(
MYSQL_BIND
*
)
0
);
mystmt_r
(
stmt
,
rc
);
bind
[
0
].
buffer_type
=
MYSQL_TYPE_GEOMETRY
;
rc
=
mysql_bind_result
(
stmt
,
bind
);
mystmt_r
(
stmt
,
rc
);
/* unsupported buffer type */
#endif
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt
(
stmt
,
rc
);
...
...
@@ -7291,9 +7278,6 @@ static void test_fetch_offset()
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch_column
(
stmt
,
bind
,
4
,
0
);
mystmt_r
(
stmt
,
rc
);
data
[
0
]
=
'\0'
;
rc
=
mysql_fetch_column
(
stmt
,
bind
,
0
,
0
);
mystmt
(
stmt
,
rc
);
...
...
@@ -7411,9 +7395,6 @@ static void test_fetch_column()
fprintf
(
stdout
,
"
\n
col 0: %d(%ld)"
,
c1
,
l1
);
assert
(
c1
==
1
&&
l1
==
4
);
rc
=
mysql_fetch_column
(
stmt
,
bind
,
10
,
0
);
mystmt_r
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
...
...
@@ -8096,6 +8077,64 @@ static void test_bug1946()
}
/*
Test for bug#2248 "mysql_fetch without prior mysql_execute hangs"
*/
static
void
test_bug2248
()
{
MYSQL_STMT
*
stmt
;
int
rc
;
const
char
*
query1
=
"SELECT DATABASE()"
;
const
char
*
query2
=
"INSERT INTO test_bug2248 VALUES (10)"
;
myheader
(
"test_bug2248"
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_bug2248"
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
"CREATE TABLE test_bug2248 (id int)"
);
myquery
(
rc
);
stmt
=
mysql_prepare
(
mysql
,
query1
,
strlen
(
query1
));
mystmt_init
(
stmt
);
/* This should not hang */
rc
=
mysql_fetch
(
stmt
);
mystmt_r
(
stmt
,
rc
);
/* And this too */
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt_r
(
stmt
,
rc
);
mysql_stmt_close
(
stmt
);
stmt
=
mysql_prepare
(
mysql
,
query2
,
strlen
(
query2
));
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
/* This too should not hang but should return proper error */
rc
=
mysql_fetch
(
stmt
);
assert
(
rc
==
MYSQL_NO_DATA
);
/* This too should not hang but should not bark */
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt
(
stmt
,
rc
);
/* This should return proper error */
rc
=
mysql_fetch
(
stmt
);
mystmt_r
(
stmt
,
rc
);
assert
(
rc
==
MYSQL_NO_DATA
);
mysql_stmt_close
(
stmt
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE test_bug2248"
);
myquery
(
rc
);
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
...
...
@@ -8340,6 +8379,7 @@ int main(int argc, char **argv)
test_bug1644
();
/* BUG#1644 */
test_bug1946
();
/* test that placeholders are allowed only in
prepared queries */
test_bug2248
();
/* BUG#2248 */
end_time
=
time
((
time_t
*
)
0
);
total_time
+=
difftime
(
end_time
,
start_time
);
...
...
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