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
14dbc7e4
Commit
14dbc7e4
authored
Sep 07, 2010
by
Dmitry Shulga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug #47485 - mysql_store_result returns a not NULL result set
for a prepared statement.
parent
24fc7ca4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
4 deletions
+110
-4
include/mysql.h
include/mysql.h
+2
-1
include/mysql.h.pp
include/mysql.h.pp
+2
-1
libmysql/libmysql.c
libmysql/libmysql.c
+4
-2
tests/mysql_client_test.c
tests/mysql_client_test.c
+102
-0
No files found.
include/mysql.h
View file @
14dbc7e4
...
@@ -224,7 +224,8 @@ struct st_mysql_options {
...
@@ -224,7 +224,8 @@ struct st_mysql_options {
enum
mysql_status
enum
mysql_status
{
{
MYSQL_STATUS_READY
,
MYSQL_STATUS_GET_RESULT
,
MYSQL_STATUS_USE_RESULT
MYSQL_STATUS_READY
,
MYSQL_STATUS_GET_RESULT
,
MYSQL_STATUS_USE_RESULT
,
MYSQL_STATUS_STATEMENT_GET_RESULT
};
};
enum
mysql_protocol_type
enum
mysql_protocol_type
...
...
include/mysql.h.pp
View file @
14dbc7e4
...
@@ -293,7 +293,8 @@ struct st_mysql_options {
...
@@ -293,7 +293,8 @@ struct st_mysql_options {
};
};
enum
mysql_status
enum
mysql_status
{
{
MYSQL_STATUS_READY
,
MYSQL_STATUS_GET_RESULT
,
MYSQL_STATUS_USE_RESULT
MYSQL_STATUS_READY
,
MYSQL_STATUS_GET_RESULT
,
MYSQL_STATUS_USE_RESULT
,
MYSQL_STATUS_STATEMENT_GET_RESULT
};
};
enum
mysql_protocol_type
enum
mysql_protocol_type
{
{
...
...
libmysql/libmysql.c
View file @
14dbc7e4
...
@@ -2503,6 +2503,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
...
@@ -2503,6 +2503,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
set_stmt_errmsg
(
stmt
,
net
);
set_stmt_errmsg
(
stmt
,
net
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
else
if
(
mysql
->
status
==
MYSQL_STATUS_GET_RESULT
)
stmt
->
mysql
->
status
=
MYSQL_STATUS_STATEMENT_GET_RESULT
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -2641,7 +2643,7 @@ static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row)
...
@@ -2641,7 +2643,7 @@ static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row)
set_stmt_error
(
stmt
,
CR_SERVER_LOST
,
unknown_sqlstate
,
NULL
);
set_stmt_error
(
stmt
,
CR_SERVER_LOST
,
unknown_sqlstate
,
NULL
);
return
1
;
return
1
;
}
}
if
(
mysql
->
status
!=
MYSQL_STATUS_GET_RESULT
)
if
(
mysql
->
status
!=
MYSQL_STATUS_
STATEMENT_
GET_RESULT
)
{
{
set_stmt_error
(
stmt
,
stmt
->
unbuffered_fetch_cancelled
?
set_stmt_error
(
stmt
,
stmt
->
unbuffered_fetch_cancelled
?
CR_FETCH_CANCELED
:
CR_COMMANDS_OUT_OF_SYNC
,
CR_FETCH_CANCELED
:
CR_COMMANDS_OUT_OF_SYNC
,
...
@@ -4847,7 +4849,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
...
@@ -4847,7 +4849,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
}
}
else
if
(
mysql
->
status
!=
MYSQL_STATUS_GET_RESULT
)
else
if
(
mysql
->
status
!=
MYSQL_STATUS_
STATEMENT_
GET_RESULT
)
{
{
set_stmt_error
(
stmt
,
CR_COMMANDS_OUT_OF_SYNC
,
unknown_sqlstate
,
NULL
);
set_stmt_error
(
stmt
,
CR_COMMANDS_OUT_OF_SYNC
,
unknown_sqlstate
,
NULL
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
...
tests/mysql_client_test.c
View file @
14dbc7e4
...
@@ -18297,6 +18297,107 @@ static void test_bug54041()
...
@@ -18297,6 +18297,107 @@ static void test_bug54041()
}
}
/**
Bug#47485: mysql_store_result returns a result set for a prepared statement
*/
static
void
test_bug47485
()
{
MYSQL_STMT
*
stmt
;
MYSQL_RES
*
res
;
MYSQL_BIND
bind
[
2
];
int
rc
;
const
char
*
sql_select
=
"SELECT 1, 'a'"
;
int
int_data
;
char
str_data
[
16
];
my_bool
is_null
[
2
];
my_bool
error
[
2
];
unsigned
long
length
[
2
];
DBUG_ENTER
(
"test_bug47485"
);
myheader
(
"test_bug47485"
);
stmt
=
mysql_stmt_init
(
mysql
);
check_stmt
(
stmt
);
rc
=
mysql_stmt_prepare
(
stmt
,
sql_select
,
strlen
(
sql_select
));
check_execute
(
stmt
,
rc
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
res
=
mysql_store_result
(
mysql
);
DIE_UNLESS
(
res
==
NULL
);
mysql_stmt_reset
(
stmt
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
res
=
mysql_use_result
(
mysql
);
DIE_UNLESS
(
res
==
NULL
);
mysql_stmt_reset
(
stmt
);
memset
(
bind
,
0
,
sizeof
(
bind
));
bind
[
0
].
buffer_type
=
MYSQL_TYPE_LONG
;
bind
[
0
].
buffer
=
(
char
*
)
&
int_data
;
bind
[
0
].
is_null
=
&
is_null
[
0
];
bind
[
0
].
length
=
&
length
[
0
];
bind
[
0
].
error
=
&
error
[
0
];
bind
[
1
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind
[
1
].
buffer
=
(
char
*
)
str_data
;
bind
[
1
].
buffer_length
=
sizeof
(
str_data
);
bind
[
1
].
is_null
=
&
is_null
[
1
];
bind
[
1
].
length
=
&
length
[
1
];
bind
[
1
].
error
=
&
error
[
1
];
rc
=
mysql_stmt_bind_result
(
stmt
,
bind
);
check_execute
(
stmt
,
rc
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
rc
=
mysql_stmt_store_result
(
stmt
);
check_execute
(
stmt
,
rc
);
while
(
!
(
rc
=
mysql_stmt_fetch
(
stmt
)))
;
DIE_UNLESS
(
rc
==
MYSQL_NO_DATA
);
mysql_stmt_reset
(
stmt
);
memset
(
bind
,
0
,
sizeof
(
bind
));
bind
[
0
].
buffer_type
=
MYSQL_TYPE_LONG
;
bind
[
0
].
buffer
=
(
char
*
)
&
int_data
;
bind
[
0
].
is_null
=
&
is_null
[
0
];
bind
[
0
].
length
=
&
length
[
0
];
bind
[
0
].
error
=
&
error
[
0
];
bind
[
1
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind
[
1
].
buffer
=
(
char
*
)
str_data
;
bind
[
1
].
buffer_length
=
sizeof
(
str_data
);
bind
[
1
].
is_null
=
&
is_null
[
1
];
bind
[
1
].
length
=
&
length
[
1
];
bind
[
1
].
error
=
&
error
[
1
];
rc
=
mysql_stmt_bind_result
(
stmt
,
bind
);
check_execute
(
stmt
,
rc
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
while
(
!
(
rc
=
mysql_stmt_fetch
(
stmt
)))
;
DIE_UNLESS
(
rc
==
MYSQL_NO_DATA
);
mysql_stmt_close
(
stmt
);
DBUG_VOID_RETURN
;
}
/*
/*
Read and parse arguments and MySQL options from my.cnf
Read and parse arguments and MySQL options from my.cnf
*/
*/
...
@@ -18622,6 +18723,7 @@ static struct my_tests_st my_tests[]= {
...
@@ -18622,6 +18723,7 @@ static struct my_tests_st my_tests[]= {
{
"test_bug44495"
,
test_bug44495
},
{
"test_bug44495"
,
test_bug44495
},
{
"test_bug42373"
,
test_bug42373
},
{
"test_bug42373"
,
test_bug42373
},
{
"test_bug54041"
,
test_bug54041
},
{
"test_bug54041"
,
test_bug54041
},
{
"test_bug47485"
,
test_bug47485
},
{
0
,
0
}
{
0
,
0
}
};
};
...
...
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