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
69f98841
Commit
69f98841
authored
Feb 13, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-limit-4.1
parents
ff9678a3
7e7fec0b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
1 deletion
+85
-1
include/mysql.h
include/mysql.h
+2
-0
libmysql/libmysql.c
libmysql/libmysql.c
+3
-1
tests/client_test.c
tests/client_test.c
+80
-0
No files found.
include/mysql.h
View file @
69f98841
...
...
@@ -534,6 +534,8 @@ typedef struct st_mysql_stmt
char
*
query
;
/* query buffer */
MEM_ROOT
mem_root
;
/* root allocations */
my_ulonglong
last_fetched_column
;
/* last fetched column */
my_ulonglong
affected_rows
;
/* copy of mysql->affected_rows
after statement execution */
unsigned
long
stmt_id
;
/* Id for prepared statement */
unsigned
int
last_errno
;
/* error code */
unsigned
int
param_count
;
/* parameters count */
...
...
libmysql/libmysql.c
View file @
69f98841
...
...
@@ -2010,6 +2010,7 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length)
set_stmt_errmsg
(
stmt
,
net
->
last_error
,
net
->
last_errno
,
net
->
sqlstate
);
DBUG_RETURN
(
1
);
}
stmt
->
affected_rows
=
mysql
->
affected_rows
;
DBUG_RETURN
(
0
);
}
...
...
@@ -2106,7 +2107,7 @@ ulong STDCALL mysql_param_count(MYSQL_STMT * stmt)
my_ulonglong
STDCALL
mysql_stmt_affected_rows
(
MYSQL_STMT
*
stmt
)
{
return
stmt
->
mysql
->
last_used_con
->
affected_rows
;
return
stmt
->
affected_rows
;
}
...
...
@@ -3173,6 +3174,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
DBUG_RETURN
(
0
);
}
mysql
->
affected_rows
=
result
->
row_count
=
result
->
data
->
rows
;
stmt
->
affected_rows
=
result
->
row_count
;
result
->
data_cursor
=
result
->
data
->
data
;
result
->
fields
=
stmt
->
fields
;
result
->
field_count
=
stmt
->
field_count
;
...
...
tests/client_test.c
View file @
69f98841
...
...
@@ -8112,6 +8112,83 @@ static void test_parse_error_and_bad_length()
fprintf
(
stdout
,
"Got error (as expected): '%s'
\n
"
,
mysql_error
(
mysql
));
}
static
void
test_bug2247
()
{
MYSQL_STMT
*
stmt
;
MYSQL_RES
*
res
;
int
rc
;
int
i
;
const
char
*
create
=
"CREATE TABLE bug2247(id INT UNIQUE AUTO_INCREMENT)"
;
const
char
*
insert
=
"INSERT INTO bug2247 VALUES (NULL)"
;
const
char
*
select
=
"SELECT id FROM bug2247"
;
const
char
*
update
=
"UPDATE bug2247 SET id=id+10"
;
const
char
*
drop
=
"DROP TABLE IF EXISTS bug2247"
;
ulonglong
exp_count
;
enum
{
NUM_ROWS
=
5
};
myheader
(
"test_bug2247"
);
fprintf
(
stdout
,
"
\n
Checking if stmt_affected_rows is not affected by
\n
"
"mysql_query ... "
);
/* create table and insert few rows */
rc
=
mysql_query
(
mysql
,
drop
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
create
);
myquery
(
rc
);
stmt
=
mysql_prepare
(
mysql
,
insert
,
strlen
(
insert
));
mystmt_init
(
stmt
);
for
(
i
=
0
;
i
<
NUM_ROWS
;
++
i
)
{
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
}
exp_count
=
mysql_stmt_affected_rows
(
stmt
);
assert
(
exp_count
==
1
);
rc
=
mysql_query
(
mysql
,
select
);
myquery
(
rc
);
/*
mysql_store_result overwrites mysql->affected_rows. Check that
mysql_stmt_affected_rows() returns the same value, whereas
mysql_affected_rows() value is correct.
*/
res
=
mysql_store_result
(
mysql
);
mytest
(
res
);
assert
(
mysql_affected_rows
(
mysql
)
==
NUM_ROWS
);
assert
(
exp_count
==
mysql_stmt_affected_rows
(
stmt
));
rc
=
mysql_query
(
mysql
,
update
);
myquery
(
rc
);
assert
(
mysql_affected_rows
(
mysql
)
==
NUM_ROWS
);
assert
(
exp_count
==
mysql_stmt_affected_rows
(
stmt
));
mysql_free_result
(
res
);
mysql_stmt_close
(
stmt
);
/* check that mysql_stmt_store_result modifies mysql_stmt_affected_rows */
stmt
=
mysql_prepare
(
mysql
,
select
,
strlen
(
select
));
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt
(
stmt
,
rc
);
exp_count
=
mysql_stmt_affected_rows
(
stmt
);
assert
(
exp_count
==
NUM_ROWS
);
rc
=
mysql_query
(
mysql
,
insert
);
myquery
(
rc
);
assert
(
mysql_affected_rows
(
mysql
)
==
1
);
assert
(
mysql_stmt_affected_rows
(
stmt
)
==
exp_count
);
mysql_stmt_close
(
stmt
);
fprintf
(
stdout
,
"OK"
);
}
/*
Test for bug#2248 "mysql_fetch without prior mysql_execute hangs"
*/
...
...
@@ -8417,6 +8494,9 @@ int main(int argc, char **argv)
test_bug2248
();
/* BUG#2248 */
test_parse_error_and_bad_length
();
/* test if bad length param in
mysql_prepare() triggers error */
test_bug2247
();
/* test that mysql_stmt_affected_rows() returns
number of rows affected by last prepared
statement execution */
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