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
0500fefb
Commit
0500fefb
authored
May 16, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/opt/local/work/mysql-5.0-9643
parents
50ff7274
5fa009aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
9 deletions
+108
-9
include/errmsg.h
include/errmsg.h
+2
-1
include/mysql.h
include/mysql.h
+7
-1
libmysql/errmsg.c
libmysql/errmsg.c
+3
-0
libmysql/libmysql.c
libmysql/libmysql.c
+33
-7
tests/mysql_client_test.c
tests/mysql_client_test.c
+63
-0
No files found.
include/errmsg.h
View file @
0500fefb
...
...
@@ -96,6 +96,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NO_DATA 2051
#define CR_NO_STMT_METADATA 2052
#define CR_NO_RESULT_SET 2053
#define CR_ERROR_LAST
/*Copy last error nr:*/
2053
#define CR_NOT_IMPLEMENTED 2054
#define CR_ERROR_LAST
/*Copy last error nr:*/
2054
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
include/mysql.h
View file @
0500fefb
...
...
@@ -664,6 +664,7 @@ typedef struct st_mysql_stmt
unsigned
char
**
row
);
unsigned
long
stmt_id
;
/* Id for prepared statement */
unsigned
long
flags
;
/* i.e. type of cursor to open */
unsigned
long
prefetch_rows
;
/* number of rows per one COM_FETCH */
/*
Copied from mysql->server_status after execute/fetch to know
server-side cursor status for this statement.
...
...
@@ -702,7 +703,12 @@ enum enum_stmt_attr_type
unsigned long with combination of cursor flags (read only, for update,
etc)
*/
STMT_ATTR_CURSOR_TYPE
STMT_ATTR_CURSOR_TYPE
,
/*
Amount of rows to retrieve from server per one fetch if using cursors.
Accepts unsigned long attribute in the range 1 - ulong_max
*/
STMT_ATTR_PREFETCH_ROWS
};
...
...
libmysql/errmsg.c
View file @
0500fefb
...
...
@@ -81,6 +81,7 @@ const char *client_errors[]=
"Attempt to read column without prior row fetch"
,
"Prepared statement contains no metadata"
,
"Attempt to read a row while there is no result set associated with the statement"
,
"This feature is not implemented yet"
,
""
};
...
...
@@ -143,6 +144,7 @@ const char *client_errors[]=
"Attempt to read column without prior row fetch"
,
"Prepared statement contains no metadata"
,
"Attempt to read a row while there is no result set associated with the statement"
,
"This feature is not implemented yet"
,
""
};
...
...
@@ -203,6 +205,7 @@ const char *client_errors[]=
"Attempt to read column without prior row fetch"
,
"Prepared statement contains no metadata"
,
"Attempt to read a row while there is no result set associated with the statement"
,
"This feature is not implemented yet"
,
""
};
#endif
...
...
libmysql/libmysql.c
View file @
0500fefb
...
...
@@ -1736,6 +1736,9 @@ myodbc_remove_escape(MYSQL *mysql,char *name)
/******************* Declarations ***********************************/
/* Default number of rows fetched per one COM_FETCH command. */
#define DEFAULT_PREFETCH_ROWS 1UL
/*
These functions are called by function pointer MYSQL_STMT::read_row_func.
...
...
@@ -1761,6 +1764,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field);
#define RESET_SERVER_SIDE 1
#define RESET_LONG_DATA 2
#define RESET_STORE_RESULT 4
static
my_bool
reset_stmt_handle
(
MYSQL_STMT
*
stmt
,
uint
flags
);
...
...
@@ -2001,6 +2005,7 @@ mysql_stmt_init(MYSQL *mysql)
stmt
->
state
=
MYSQL_STMT_INIT_DONE
;
stmt
->
mysql
=
mysql
;
stmt
->
read_row_func
=
stmt_read_row_no_data
;
stmt
->
prefetch_rows
=
DEFAULT_PREFETCH_ROWS
;
/* The rest of statement members was bzeroed inside malloc */
DBUG_RETURN
(
stmt
);
...
...
@@ -2059,7 +2064,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
/* This is second prepare with another statement */
char
buff
[
MYSQL_STMT_HEADER
];
/* 4 bytes - stmt id */
if
(
reset_stmt_handle
(
stmt
,
RESET_LONG_DATA
))
if
(
reset_stmt_handle
(
stmt
,
RESET_LONG_DATA
|
RESET_STORE_RESULT
))
DBUG_RETURN
(
1
);
/*
These members must be reset for API to
...
...
@@ -2714,7 +2719,7 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row)
result
->
rows
=
0
;
/* Send row request to the server */
int4store
(
buff
,
stmt
->
stmt_id
);
int4store
(
buff
+
4
,
1
);
/* number of rows to fetch */
int4store
(
buff
+
4
,
stmt
->
prefetch_rows
);
/* number of rows to fetch */
if
(
cli_advanced_command
(
mysql
,
COM_FETCH
,
buff
,
sizeof
(
buff
),
NullS
,
0
,
1
))
{
...
...
@@ -2772,12 +2777,29 @@ my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
stmt
->
update_max_length
=
value
?
*
(
const
my_bool
*
)
value
:
0
;
break
;
case
STMT_ATTR_CURSOR_TYPE
:
stmt
->
flags
=
value
?
*
(
const
unsigned
long
*
)
value
:
0
;
{
ulong
cursor_type
;
cursor_type
=
value
?
*
(
ulong
*
)
value
:
0UL
;
if
(
cursor_type
>
(
ulong
)
CURSOR_TYPE_READ_ONLY
)
goto
err_not_implemented
;
stmt
->
flags
=
cursor_type
;
break
;
}
case
STMT_ATTR_PREFETCH_ROWS
:
{
ulong
prefetch_rows
=
value
?
*
(
ulong
*
)
value
:
DEFAULT_PREFETCH_ROWS
;
if
(
value
==
0
)
return
TRUE
;
stmt
->
prefetch_rows
=
prefetch_rows
;
break
;
}
default:
return
TRUE
;
goto
err_not_implemented
;
}
return
FALSE
;
err_not_implemented:
set_stmt_error
(
stmt
,
CR_NOT_IMPLEMENTED
,
unknown_sqlstate
);
return
TRUE
;
}
...
...
@@ -2854,7 +2876,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
DBUG_RETURN
(
1
);
}
if
(
reset_stmt_handle
(
stmt
,
0
))
if
(
reset_stmt_handle
(
stmt
,
RESET_STORE_RESULT
))
DBUG_RETURN
(
1
);
/*
No need to check for stmt->state: if the statement wasn't
...
...
@@ -4862,7 +4884,11 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
MYSQL_DATA
*
result
=
&
stmt
->
result
;
my_bool
has_cursor
=
stmt
->
read_row_func
==
stmt_read_row_from_cursor
;
if
(
result
->
data
)
/*
Reset stored result set if so was requested or it's a part
of cursor fetch.
*/
if
(
result
->
data
&&
(
has_cursor
||
(
flags
&
RESET_STORE_RESULT
)))
{
/* Result buffered */
free_root
(
&
result
->
alloc
,
MYF
(
MY_KEEP_PREALLOC
));
...
...
@@ -4921,7 +4947,7 @@ my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
DBUG_ENTER
(
"mysql_stmt_free_result"
);
/* Free the client side and close the server side cursor if there is one */
DBUG_RETURN
(
reset_stmt_handle
(
stmt
,
RESET_LONG_DATA
));
DBUG_RETURN
(
reset_stmt_handle
(
stmt
,
RESET_LONG_DATA
|
RESET_STORE_RESULT
));
}
/********************************************************************
...
...
tests/mysql_client_test.c
View file @
0500fefb
...
...
@@ -13078,6 +13078,68 @@ static void test_bug9478()
}
/*
Error message is returned for unsupported features.
Test also cursors with non-default PREFETCH_ROWS
*/
static
void
test_bug9643
()
{
MYSQL_STMT
*
stmt
;
MYSQL_BIND
bind
[
1
];
int32
a
;
int
rc
;
const
char
*
stmt_text
;
int
num_rows
=
0
;
ulong
type
;
ulong
prefetch_rows
=
5
;
myheader
(
"test_bug9643"
);
mysql_query
(
mysql
,
"drop table if exists t1"
);
mysql_query
(
mysql
,
"create table t1 (id integer not null primary key)"
);
rc
=
mysql_query
(
mysql
,
"insert into t1 (id) values "
" (1), (2), (3), (4), (5), (6), (7), (8), (9)"
);
myquery
(
rc
);
stmt
=
mysql_stmt_init
(
mysql
);
/* Not implemented in 5.0 */
type
=
(
ulong
)
CURSOR_TYPE_SCROLLABLE
;
rc
=
mysql_stmt_attr_set
(
stmt
,
STMT_ATTR_CURSOR_TYPE
,
(
void
*
)
&
type
);
DIE_UNLESS
(
rc
);
if
(
!
opt_silent
)
printf
(
"Got error (as expected): %s
\n
"
,
mysql_stmt_error
(
stmt
));
type
=
(
ulong
)
CURSOR_TYPE_READ_ONLY
;
rc
=
mysql_stmt_attr_set
(
stmt
,
STMT_ATTR_CURSOR_TYPE
,
(
void
*
)
&
type
);
check_execute
(
stmt
,
rc
);
rc
=
mysql_stmt_attr_set
(
stmt
,
STMT_ATTR_PREFETCH_ROWS
,
(
void
*
)
&
prefetch_rows
);
check_execute
(
stmt
,
rc
);
stmt_text
=
"select * from t1"
;
rc
=
mysql_stmt_prepare
(
stmt
,
stmt_text
,
strlen
(
stmt_text
));
check_execute
(
stmt
,
rc
);
bzero
(
bind
,
sizeof
(
bind
));
bind
[
0
].
buffer_type
=
MYSQL_TYPE_LONG
;
bind
[
0
].
buffer
=
(
void
*
)
&
a
;
bind
[
0
].
buffer_length
=
sizeof
(
a
);
mysql_stmt_bind_result
(
stmt
,
bind
);
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
while
((
rc
=
mysql_stmt_fetch
(
stmt
))
==
0
)
++
num_rows
;
DIE_UNLESS
(
num_rows
==
9
);
rc
=
mysql_stmt_close
(
stmt
);
DIE_UNLESS
(
rc
==
0
);
rc
=
mysql_query
(
mysql
,
"drop table t1"
);
myquery
(
rc
);
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
...
...
@@ -13309,6 +13371,7 @@ static struct my_tests_st my_tests[]= {
{
"test_bug9159"
,
test_bug9159
},
{
"test_bug9520"
,
test_bug9520
},
{
"test_bug9478"
,
test_bug9478
},
{
"test_bug9643"
,
test_bug9643
},
{
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