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
1f880250
Commit
1f880250
authored
Mar 04, 2003
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix EXPLAIN bug with binary protocol
Added new client tests (EXPLAIN + DECIMAL conv)
parent
6a9273fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
247 additions
and
28 deletions
+247
-28
sql/sql_prepare.cc
sql/sql_prepare.cc
+31
-23
tests/client_test.c
tests/client_test.c
+216
-5
No files found.
sql/sql_prepare.cc
View file @
1f880250
...
...
@@ -572,34 +572,42 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
if
(
open_and_lock_tables
(
thd
,
tables
))
DBUG_RETURN
(
1
);
fix_tables_pointers
(
thd
->
lex
.
all_selects_list
);
if
(
!
result
&&
!
(
result
=
new
select_send
())
)
if
(
lex
->
describe
)
{
delete
select_lex
->
having
;
delete
select_lex
->
where
;
send_error
(
thd
,
ER_OUT_OF_RESOURCES
);
DBUG_RETURN
(
1
);
}
if
(
!
(
result
=
new
select_send
()))
{
send_error
(
thd
,
ER_OUT_OF_RESOURCES
);
DBUG_RETURN
(
1
);
}
if
(
send_prep_stmt
(
stmt
,
0
)
||
send_item_params
(
stmt
))
DBUG_RETURN
(
1
);
}
else
{
fix_tables_pointers
(
thd
->
lex
.
all_selects_list
);
if
(
!
result
&&
!
(
result
=
new
select_send
()))
{
delete
select_lex
->
having
;
delete
select_lex
->
where
;
send_error
(
thd
,
ER_OUT_OF_RESOURCES
);
DBUG_RETURN
(
1
);
}
JOIN
*
join
=
new
JOIN
(
thd
,
fields
,
select_options
,
result
);
thd
->
used_tables
=
0
;
// Updated by setup_fields
JOIN
*
join
=
new
JOIN
(
thd
,
fields
,
select_options
,
result
);
thd
->
used_tables
=
0
;
// Updated by setup_fields
if
(
join
->
prepare
(
&
select_lex
->
ref_pointer_array
,
tables
,
wild_num
,
conds
,
og_num
,
order
,
group
,
having
,
proc
,
select_lex
,
unit
,
0
,
0
))
DBUG_RETURN
(
1
);
if
(
join
->
prepare
(
&
select_lex
->
ref_pointer_array
,
tables
,
wild_num
,
conds
,
og_num
,
order
,
group
,
having
,
proc
,
select_lex
,
unit
,
0
,
0
))
DBUG_RETURN
(
1
);
/*
Currently return only column list info only, and we are not
sending any info on where clause.
*/
if
(
send_prep_stmt
(
stmt
,
fields
.
elements
)
||
thd
->
protocol_simple
.
send_fields
(
&
fields
,
0
)
||
send_item_params
(
stmt
))
DBUG_RETURN
(
1
);
join
->
cleanup
(
thd
);
if
(
send_prep_stmt
(
stmt
,
fields
.
elements
)
||
thd
->
protocol_simple
.
send_fields
(
&
fields
,
0
)
||
send_item_params
(
stmt
))
DBUG_RETURN
(
1
);
join
->
cleanup
(
thd
);
}
DBUG_RETURN
(
0
);
}
...
...
tests/client_test.c
View file @
1f880250
...
...
@@ -5926,7 +5926,7 @@ static void test_field_misc()
/*
To test SET OPTION feature with prepare stmts
bug #85
bug #85
(reported by mark@mysql.com)
*/
static
void
test_set_option
()
{
...
...
@@ -5991,7 +5991,7 @@ static void test_set_option()
/*
To test a misc GRANT option
bug #89
bug #89
(reported by mark@mysql.com)
*/
static
void
test_prepare_grant
()
{
...
...
@@ -6084,8 +6084,8 @@ static void test_prepare_grant()
/*
To test a crash when invalid/corrupted .frm is used in the
SHOW TABLE STATUS
(in debug mode)
bug #93
SHOW TABLE STATUS
bug #93
(reported by serg@mysql.com).
*/
static
void
test_frm_bug
()
{
...
...
@@ -6167,6 +6167,215 @@ static void test_frm_bug()
mysql_query
(
mysql
,
"drop table if exists test_frm_bug"
);
}
/*
To test DECIMAL conversion
*/
static
void
test_decimal_bug
()
{
MYSQL_STMT
*
stmt
;
MYSQL_BIND
bind
[
1
];
double
data
;
int
rc
;
my_bool
is_null
;
myheader
(
"test_decimal_bug"
);
mysql_autocommit
(
mysql
,
TRUE
);
rc
=
mysql_query
(
mysql
,
"drop table if exists test_decimal_bug"
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
"create table test_decimal_bug(c1 decimal(10,2))"
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
"insert into test_decimal_bug value(8),(10.22),(5.61)"
);
myquery
(
rc
);
stmt
=
mysql_prepare
(
mysql
,
"select c1 from test_decimal_bug where c1= ?"
,
50
);
mystmt_init
(
stmt
);
bind
[
0
].
buffer_type
=
MYSQL_TYPE_DOUBLE
;
bind
[
0
].
buffer
=
(
char
*
)
&
data
;
bind
[
0
].
buffer_length
=
0
;
bind
[
0
].
is_null
=
&
is_null
;
bind
[
0
].
length
=
0
;
is_null
=
0
;
rc
=
mysql_bind_param
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
data
=
8
.
0
;
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
data
=
0
;
rc
=
mysql_bind_result
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
fprintf
(
stdout
,
"
\n
data: %g"
,
data
);
myassert
(
data
==
8
.
0
);
rc
=
mysql_fetch
(
stmt
);
myassert
(
rc
==
MYSQL_NO_DATA
);
data
=
5
.
61
;
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
data
=
0
;
rc
=
mysql_bind_result
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
fprintf
(
stdout
,
"
\n
data: %g"
,
data
);
myassert
(
data
==
5
.
61
);
rc
=
mysql_fetch
(
stmt
);
myassert
(
rc
==
MYSQL_NO_DATA
);
is_null
=
1
;
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
myassert
(
rc
==
MYSQL_NO_DATA
);
data
=
10
.
22
;
is_null
=
0
;
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
data
=
0
;
rc
=
mysql_bind_result
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
fprintf
(
stdout
,
"
\n
data: %g"
,
data
);
myassert
(
data
==
10
.
22
);
rc
=
mysql_fetch
(
stmt
);
myassert
(
rc
==
MYSQL_NO_DATA
);
mysql_stmt_close
(
stmt
);
}
/*
To test EXPLAIN bug
bug #115 (reported by mark@mysql.com & georg@php.net).
*/
static
void
test_explain_bug
()
{
MYSQL_STMT
*
stmt
;
MYSQL_RES
*
result
;
int
rc
;
myheader
(
"test_explain_bug"
);
mysql_autocommit
(
mysql
,
TRUE
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_explain"
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
"CREATE TABLE test_explain(id int, name char(2))"
);
myquery
(
rc
);
stmt
=
mysql_prepare
(
mysql
,
"explain test_explain"
,
30
);
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
myassert
(
2
==
my_process_stmt_result
(
stmt
));
result
=
mysql_prepare_result
(
stmt
);
mytest
(
result
);
fprintf
(
stdout
,
"
\n
total fields in the result: %d"
,
mysql_num_fields
(
result
));
myassert
(
7
==
mysql_num_fields
(
result
));
verify_prepare_field
(
result
,
0
,
"Field"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
NAME_LEN
);
verify_prepare_field
(
result
,
1
,
"Type"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
40
);
verify_prepare_field
(
result
,
2
,
"Collation"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
40
);
verify_prepare_field
(
result
,
3
,
"Null"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
1
);
verify_prepare_field
(
result
,
4
,
"Key"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
3
);
verify_prepare_field
(
result
,
5
,
"Default"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
NAME_LEN
);
verify_prepare_field
(
result
,
6
,
"Extra"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
20
);
mysql_free_result
(
result
);
mysql_stmt_close
(
stmt
);
stmt
=
mysql_prepare
(
mysql
,
"explain select id, name FROM test_explain"
,
50
);
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
myassert
(
1
==
my_process_stmt_result
(
stmt
));
result
=
mysql_prepare_result
(
stmt
);
mytest
(
result
);
fprintf
(
stdout
,
"
\n
total fields in the result: %d"
,
mysql_num_fields
(
result
));
myassert
(
10
==
mysql_num_fields
(
result
));
verify_prepare_field
(
result
,
0
,
"id"
,
""
,
MYSQL_TYPE_LONGLONG
,
""
,
""
,
""
,
3
);
verify_prepare_field
(
result
,
1
,
"select_type"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
19
);
verify_prepare_field
(
result
,
2
,
"table"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
NAME_LEN
);
verify_prepare_field
(
result
,
3
,
"type"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
10
);
verify_prepare_field
(
result
,
4
,
"possible_keys"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
NAME_LEN
*
32
);
verify_prepare_field
(
result
,
5
,
"key"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
NAME_LEN
);
verify_prepare_field
(
result
,
6
,
"key_len"
,
""
,
MYSQL_TYPE_LONGLONG
,
""
,
""
,
""
,
3
);
verify_prepare_field
(
result
,
7
,
"ref"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
NAME_LEN
*
16
);
verify_prepare_field
(
result
,
8
,
"rows"
,
""
,
MYSQL_TYPE_LONGLONG
,
""
,
""
,
""
,
10
);
verify_prepare_field
(
result
,
9
,
"Extra"
,
""
,
MYSQL_TYPE_STRING
,
""
,
""
,
""
,
255
);
mysql_free_result
(
result
);
mysql_stmt_close
(
stmt
);
}
/*
Read and parse arguments and MySQL options from my.cnf
...
...
@@ -6385,10 +6594,12 @@ int main(int argc, char **argv)
test_ushort_bug
();
/* test a simple conv bug from php */
test_sshort_bug
();
/* test a simple conv bug from php */
test_stiny_bug
();
/* test a simple conv bug from php */
test_field_misc
();
/* check the field info for misc case, bug: #74 */
test_field_misc
();
/* check the field info for misc case, bug: #74 */
test_set_option
();
/* test the SET OPTION feature, bug #85 */
test_prepare_grant
();
/* to test the GRANT command, bug #89 */
test_frm_bug
();
/* test the crash when .frm is invalid, bug #93 */
test_explain_bug
();
/* test for the EXPLAIN, bug #115 */
test_decimal_bug
();
/* test for the decimal bug */
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