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
5e54670a
Commit
5e54670a
authored
Mar 05, 2004
by
ingo@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge istruewing@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/mydev/mysql/mysql-4.1
parents
235f0ffe
ce2db5c3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
169 additions
and
91 deletions
+169
-91
include/mysql.h
include/mysql.h
+43
-21
libmysql/client_settings.h
libmysql/client_settings.h
+1
-1
libmysql/libmysql.c
libmysql/libmysql.c
+93
-54
sql-common/client.c
sql-common/client.c
+1
-1
tests/client_test.c
tests/client_test.c
+31
-14
No files found.
include/mysql.h
View file @
5e54670a
...
@@ -77,6 +77,8 @@ extern char *mysql_unix_port;
...
@@ -77,6 +77,8 @@ extern char *mysql_unix_port;
#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
#define HAVE_DEPRECATED_411_API 1
typedef
struct
st_mysql_field
{
typedef
struct
st_mysql_field
{
char
*
name
;
/* Name of column */
char
*
name
;
/* Name of column */
char
*
org_name
;
/* Original column name, if an alias */
char
*
org_name
;
/* Original column name, if an alias */
...
@@ -579,40 +581,60 @@ typedef struct st_mysql_methods
...
@@ -579,40 +581,60 @@ typedef struct st_mysql_methods
#endif
#endif
}
MYSQL_METHODS
;
}
MYSQL_METHODS
;
#ifdef HAVE_DEPRECATED_411_API
/* Deprecated calls (since MySQL 4.1.2) */
/* Use mysql_stmt_init + mysql_stmt_prepare instead */
MYSQL_STMT
*
STDCALL
mysql_prepare
(
MYSQL
*
mysql
,
const
char
*
query
,
MYSQL_STMT
*
STDCALL
mysql_prepare
(
MYSQL
*
mysql
,
const
char
*
query
,
unsigned
long
length
);
unsigned
long
length
);
int
STDCALL
mysql_execute
(
MYSQL_STMT
*
stmt
);
#define mysql_execute mysql_stmt_execute
unsigned
long
STDCALL
mysql_param_count
(
MYSQL_STMT
*
stmt
);
#define mysql_fetch mysql_stmt_fetch
my_bool
STDCALL
mysql_bind_param
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bnd
);
#define mysql_fetch_column mysql_stmt_fetch_column
my_bool
STDCALL
mysql_bind_result
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bnd
);
#define mysql_bind_param mysql_stmt_bind_param
#define mysql_bind_result mysql_stmt_bind_result
#define mysql_param_count mysql_stmt_param_count
#define mysql_param_result mysql_stmt_param_metadata
#define mysql_get_metadata mysql_stmt_result_metadata
#define mysql_send_long_data mysql_stmt_send_long_data
#endif
/* HAVE_DEPRECATED_411_API */
MYSQL_STMT
*
STDCALL
mysql_stmt_init
(
MYSQL
*
mysql
);
int
STDCALL
mysql_stmt_prepare
(
MYSQL_STMT
*
stmt
,
const
char
*
query
,
unsigned
long
length
);
int
STDCALL
mysql_stmt_execute
(
MYSQL_STMT
*
stmt
);
int
STDCALL
mysql_stmt_fetch
(
MYSQL_STMT
*
stmt
);
int
STDCALL
mysql_stmt_fetch_column
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
,
unsigned
int
column
,
unsigned
long
offset
);
int
STDCALL
mysql_stmt_store_result
(
MYSQL_STMT
*
stmt
);
unsigned
long
STDCALL
mysql_stmt_param_count
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_bind_param
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bnd
);
my_bool
STDCALL
mysql_stmt_bind_result
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bnd
);
my_bool
STDCALL
mysql_stmt_close
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_close
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_reset
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_reset
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_free_result
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_free_result
(
MYSQL_STMT
*
stmt
);
unsigned
int
STDCALL
mysql_stmt_errno
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_stmt_send_long_data
(
MYSQL_STMT
*
stmt
,
const
char
*
STDCALL
mysql_stmt_error
(
MYSQL_STMT
*
stmt
);
const
char
*
STDCALL
mysql_stmt_sqlstate
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_commit
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_rollback
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_autocommit
(
MYSQL
*
mysql
,
my_bool
auto_mode
);
int
STDCALL
mysql_fetch
(
MYSQL_STMT
*
stmt
);
int
STDCALL
mysql_fetch_column
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
,
unsigned
int
column
,
unsigned
long
offset
);
my_bool
STDCALL
mysql_send_long_data
(
MYSQL_STMT
*
stmt
,
unsigned
int
param_number
,
unsigned
int
param_number
,
const
char
*
data
,
const
char
*
data
,
unsigned
long
length
);
unsigned
long
length
);
MYSQL_RES
*
STDCALL
mysql_get_metadata
(
MYSQL_STMT
*
stmt
);
MYSQL_RES
*
STDCALL
mysql_stmt_result_metadata
(
MYSQL_STMT
*
stmt
);
MYSQL_RES
*
STDCALL
mysql_param_result
(
MYSQL_STMT
*
stmt
);
MYSQL_RES
*
STDCALL
mysql_stmt_param_metadata
(
MYSQL_STMT
*
stmt
);
my_ulonglong
STDCALL
mysql_stmt_affected_rows
(
MYSQL_STMT
*
stmt
);
unsigned
int
STDCALL
mysql_stmt_errno
(
MYSQL_STMT
*
stmt
);
int
STDCALL
mysql_stmt_store_result
(
MYSQL_STMT
*
stmt
);
const
char
*
STDCALL
mysql_stmt_error
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_more_results
(
MYSQL
*
mysql
);
const
char
*
STDCALL
mysql_stmt_sqlstate
(
MYSQL_STMT
*
stmt
);
int
STDCALL
mysql_next_result
(
MYSQL
*
mysql
);
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_seek
(
MYSQL_STMT
*
stmt
,
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_seek
(
MYSQL_STMT
*
stmt
,
MYSQL_ROW_OFFSET
offset
);
MYSQL_ROW_OFFSET
offset
);
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_tell
(
MYSQL_STMT
*
stmt
);
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_tell
(
MYSQL_STMT
*
stmt
);
void
STDCALL
mysql_stmt_data_seek
(
MYSQL_STMT
*
stmt
,
my_ulonglong
offset
);
void
STDCALL
mysql_stmt_data_seek
(
MYSQL_STMT
*
stmt
,
my_ulonglong
offset
);
my_ulonglong
STDCALL
mysql_stmt_num_rows
(
MYSQL_STMT
*
stmt
);
my_ulonglong
STDCALL
mysql_stmt_num_rows
(
MYSQL_STMT
*
stmt
);
my_ulonglong
STDCALL
mysql_stmt_affected_rows
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_commit
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_rollback
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_autocommit
(
MYSQL
*
mysql
,
my_bool
auto_mode
);
my_bool
STDCALL
mysql_more_results
(
MYSQL
*
mysql
);
int
STDCALL
mysql_next_result
(
MYSQL
*
mysql
);
void
STDCALL
mysql_close
(
MYSQL
*
sock
);
void
STDCALL
mysql_close
(
MYSQL
*
sock
);
...
...
libmysql/client_settings.h
View file @
5e54670a
...
@@ -22,7 +22,7 @@ extern my_string mysql_unix_port;
...
@@ -22,7 +22,7 @@ extern my_string mysql_unix_port;
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
sig_handler
pipe_sig_handler
(
int
sig
__attribute__
((
unused
)));
sig_handler
pipe_sig_handler
(
int
sig
__attribute__
((
unused
)));
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_
list
,
my_bool
skip_
free
);
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_free
);
void
read_user_name
(
char
*
name
);
void
read_user_name
(
char
*
name
);
my_bool
send_file_to_server
(
MYSQL
*
mysql
,
const
char
*
filename
);
my_bool
send_file_to_server
(
MYSQL
*
mysql
,
const
char
*
filename
);
...
...
libmysql/libmysql.c
View file @
5e54670a
...
@@ -89,7 +89,6 @@ static void append_wild(char *to,char *end,const char *wild);
...
@@ -89,7 +89,6 @@ static void append_wild(char *to,char *end,const char *wild);
sig_handler
pipe_sig_handler
(
int
sig
);
sig_handler
pipe_sig_handler
(
int
sig
);
static
ulong
mysql_sub_escape_string
(
CHARSET_INFO
*
charset_info
,
char
*
to
,
static
ulong
mysql_sub_escape_string
(
CHARSET_INFO
*
charset_info
,
char
*
to
,
const
char
*
from
,
ulong
length
);
const
char
*
from
,
ulong
length
);
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_list
,
my_bool
skip_free
);
static
my_bool
mysql_client_init
=
0
;
static
my_bool
mysql_client_init
=
0
;
static
my_bool
org_my_init_done
=
0
;
static
my_bool
org_my_init_done
=
0
;
...
@@ -1640,43 +1639,88 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
...
@@ -1640,43 +1639,88 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
#ifdef HAVE_DEPRECATED_411_API
MYSQL_STMT
*
STDCALL
mysql_prepare
(
MYSQL
*
mysql
,
const
char
*
query
,
unsigned
long
query_length
)
{
DBUG_ENTER
(
"mysql_prepare"
);
MYSQL_STMT
*
stmt
=
mysql_stmt_init
(
mysql
);
if
(
stmt
&&
mysql_stmt_prepare
(
stmt
,
query
,
query_length
))
{
stmt_close
(
stmt
,
0
);
DBUG_RETURN
(
0
);
}
DBUG_RETURN
(
stmt
);
}
#endif
/*
/*
Prepare the query and return the new statement handle to
Allocate memory and init prepared statement structure
caller.
SYNOPSIS
mysql_stmt_init()
mysql connection handle
RETURN VALUE
statement structure upon success and NULL if out of
memory
*/
MYSQL_STMT
*
STDCALL
mysql_stmt_init
(
MYSQL
*
mysql
)
{
MYSQL_STMT
*
stmt
;
DBUG_ENTER
(
"mysql_stmt_init"
);
if
(
!
(
stmt
=
(
MYSQL_STMT
*
)
my_malloc
(
sizeof
(
MYSQL_STMT
),
MYF
(
MY_WME
|
MY_ZEROFILL
))))
{
set_mysql_error
(
mysql
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
DBUG_RETURN
(
0
);
}
init_alloc_root
(
&
stmt
->
mem_root
,
8192
,
0
);
mysql
->
stmts
=
list_add
(
mysql
->
stmts
,
&
stmt
->
list
);
stmt
->
list
.
data
=
stmt
;
stmt
->
state
=
MY_ST_UNKNOWN
;
stmt
->
mysql
=
mysql
;
DBUG_RETURN
(
stmt
);
}
/*
Prepare server side statement with query.
Also update the total parameter count along with resultset
Also update the total parameter count along with resultset
metadata information by reading from server
metadata information by reading from server
*/
*/
MYSQL_STMT
*
STDCALL
int
STDCALL
mysql_
prepare
(
MYSQL
*
mysql
,
const
char
*
query
,
ulong
length
)
mysql_
stmt_prepare
(
MYSQL_STMT
*
stmt
,
const
char
*
query
,
ulong
length
)
{
{
MYSQL_STMT
*
stmt
;
MYSQL
*
mysql
=
stmt
->
mysql
;
DBUG_ENTER
(
"mysql_prepare"
);
DBUG_ENTER
(
"mysql_stmt_prepare"
);
DBUG_ASSERT
(
mysql
!=
0
);
DBUG_ASSERT
(
mysql
!=
0
);
if
(
!
(
stmt
=
(
MYSQL_STMT
*
)
my_malloc
(
sizeof
(
MYSQL_STMT
),
/* In case we reprepare this handle with another statement */
MYF
(
MY_WME
|
MY_ZEROFILL
)))
||
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
!
(
stmt
->
query
=
my_strdup_with_length
((
byte
*
)
query
,
length
,
MYF
(
0
))))
/* stmt->query is never used yet */
if
(
!
(
stmt
->
query
=
strmake_root
(
&
stmt
->
mem_root
,
query
,
length
)))
{
{
my_free
((
gptr
)
stmt
,
MYF
(
MY_ALLOW_ZERO_PTR
));
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
set_mysql_error
(
mysql
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
0
);
}
}
if
(
simple_command
(
mysql
,
COM_PREPARE
,
query
,
length
,
1
))
if
(
simple_command
(
mysql
,
COM_PREPARE
,
query
,
length
,
1
))
{
{
stmt_close
(
stmt
,
1
,
0
);
set_stmt_errmsg
(
stmt
,
mysql
->
net
.
last_error
,
mysql
->
net
.
last_errno
,
DBUG_RETURN
(
0
);
mysql
->
net
.
sqlstate
);
DBUG_RETURN
(
1
);
}
}
init_alloc_root
(
&
stmt
->
mem_root
,
8192
,
0
);
if
((
*
mysql
->
methods
->
read_prepare_result
)(
mysql
,
stmt
))
if
((
*
mysql
->
methods
->
read_prepare_result
)(
mysql
,
stmt
))
{
DBUG_RETURN
(
1
);
stmt_close
(
stmt
,
1
,
0
);
DBUG_RETURN
(
0
);
}
if
(
!
(
stmt
->
params
=
(
MYSQL_BIND
*
)
alloc_root
(
&
stmt
->
mem_root
,
if
(
!
(
stmt
->
params
=
(
MYSQL_BIND
*
)
alloc_root
(
&
stmt
->
mem_root
,
sizeof
(
MYSQL_BIND
)
*
sizeof
(
MYSQL_BIND
)
*
...
@@ -1684,16 +1728,13 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
...
@@ -1684,16 +1728,13 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
stmt
->
field_count
))))
stmt
->
field_count
))))
{
{
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
1
);
}
}
stmt
->
bind
=
stmt
->
params
+
stmt
->
param_count
;
stmt
->
bind
=
stmt
->
params
+
stmt
->
param_count
;
stmt
->
state
=
MY_ST_PREPARE
;
stmt
->
state
=
MY_ST_PREPARE
;
stmt
->
mysql
=
mysql
;
mysql
->
stmts
=
list_add
(
mysql
->
stmts
,
&
stmt
->
list
);
mysql
->
status
=
MYSQL_STATUS_READY
;
mysql
->
status
=
MYSQL_STATUS_READY
;
stmt
->
list
.
data
=
stmt
;
DBUG_PRINT
(
"info"
,
(
"Parameter count: %ld"
,
stmt
->
param_count
));
DBUG_PRINT
(
"info"
,
(
"Parameter count: %ld"
,
stmt
->
param_count
));
DBUG_RETURN
(
stmt
);
DBUG_RETURN
(
0
);
}
}
/*
/*
...
@@ -1750,10 +1791,10 @@ unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
...
@@ -1750,10 +1791,10 @@ unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
*/
*/
MYSQL_RES
*
STDCALL
MYSQL_RES
*
STDCALL
mysql_
ge
t_metadata
(
MYSQL_STMT
*
stmt
)
mysql_
stmt_resul
t_metadata
(
MYSQL_STMT
*
stmt
)
{
{
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
DBUG_ENTER
(
"mysql_
ge
t_metadata"
);
DBUG_ENTER
(
"mysql_
stmt_resul
t_metadata"
);
if
(
!
stmt
->
field_count
||
!
stmt
->
fields
)
if
(
!
stmt
->
field_count
||
!
stmt
->
fields
)
{
{
...
@@ -1778,9 +1819,9 @@ mysql_get_metadata(MYSQL_STMT *stmt)
...
@@ -1778,9 +1819,9 @@ mysql_get_metadata(MYSQL_STMT *stmt)
*/
*/
MYSQL_RES
*
STDCALL
MYSQL_RES
*
STDCALL
mysql_
param_result
(
MYSQL_STMT
*
stmt
)
mysql_
stmt_param_metadata
(
MYSQL_STMT
*
stmt
)
{
{
DBUG_ENTER
(
"mysql_
param_result
"
);
DBUG_ENTER
(
"mysql_
stmt_param_metadata
"
);
if
(
!
stmt
->
param_count
)
if
(
!
stmt
->
param_count
)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -2079,9 +2120,9 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
...
@@ -2079,9 +2120,9 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
Execute the prepared query
Execute the prepared query
*/
*/
int
STDCALL
mysql_execute
(
MYSQL_STMT
*
stmt
)
int
STDCALL
mysql_
stmt_
execute
(
MYSQL_STMT
*
stmt
)
{
{
DBUG_ENTER
(
"mysql_execute"
);
DBUG_ENTER
(
"mysql_
stmt_
execute"
);
if
((
*
stmt
->
mysql
->
methods
->
stmt_execute
)(
stmt
))
if
((
*
stmt
->
mysql
->
methods
->
stmt_execute
)(
stmt
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
@@ -2099,9 +2140,9 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
...
@@ -2099,9 +2140,9 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
Return total parameters count in the statement
Return total parameters count in the statement
*/
*/
ulong
STDCALL
mysql_param_count
(
MYSQL_STMT
*
stmt
)
ulong
STDCALL
mysql_
stmt_
param_count
(
MYSQL_STMT
*
stmt
)
{
{
DBUG_ENTER
(
"mysql_param_count"
);
DBUG_ENTER
(
"mysql_
stmt_
param_count"
);
DBUG_RETURN
(
stmt
->
param_count
);
DBUG_RETURN
(
stmt
->
param_count
);
}
}
...
@@ -2122,11 +2163,11 @@ static my_bool int_is_null_false= 0;
...
@@ -2122,11 +2163,11 @@ static my_bool int_is_null_false= 0;
Setup the parameter data buffers from application
Setup the parameter data buffers from application
*/
*/
my_bool
STDCALL
mysql_bind_param
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
)
my_bool
STDCALL
mysql_
stmt_
bind_param
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
)
{
{
uint
count
=
0
;
uint
count
=
0
;
MYSQL_BIND
*
param
,
*
end
;
MYSQL_BIND
*
param
,
*
end
;
DBUG_ENTER
(
"mysql_bind_param"
);
DBUG_ENTER
(
"mysql_
stmt_
bind_param"
);
/* Allocated on prepare */
/* Allocated on prepare */
memcpy
((
char
*
)
stmt
->
params
,
(
char
*
)
bind
,
memcpy
((
char
*
)
stmt
->
params
,
(
char
*
)
bind
,
...
@@ -2228,7 +2269,7 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
...
@@ -2228,7 +2269,7 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
Send long data in pieces to the server
Send long data in pieces to the server
SYNOPSIS
SYNOPSIS
mysql_send_long_data()
mysql_s
tmt_s
end_long_data()
stmt Statement handler
stmt Statement handler
param_number Parameter number (0 - N-1)
param_number Parameter number (0 - N-1)
data Data to send to server
data Data to send to server
...
@@ -2241,11 +2282,11 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
...
@@ -2241,11 +2282,11 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
my_bool
STDCALL
my_bool
STDCALL
mysql_send_long_data
(
MYSQL_STMT
*
stmt
,
uint
param_number
,
mysql_s
tmt_s
end_long_data
(
MYSQL_STMT
*
stmt
,
uint
param_number
,
const
char
*
data
,
ulong
length
)
const
char
*
data
,
ulong
length
)
{
{
MYSQL_BIND
*
param
;
MYSQL_BIND
*
param
;
DBUG_ENTER
(
"mysql_send_long_data"
);
DBUG_ENTER
(
"mysql_s
tmt_s
end_long_data"
);
DBUG_ASSERT
(
stmt
!=
0
);
DBUG_ASSERT
(
stmt
!=
0
);
DBUG_PRINT
(
"enter"
,(
"param no : %d, data : %lx, length : %ld"
,
DBUG_PRINT
(
"enter"
,(
"param no : %d, data : %lx, length : %ld"
,
param_number
,
data
,
length
));
param_number
,
data
,
length
));
...
@@ -2811,12 +2852,12 @@ static void fetch_result_str(MYSQL_BIND *param, uchar **row)
...
@@ -2811,12 +2852,12 @@ static void fetch_result_str(MYSQL_BIND *param, uchar **row)
Setup the bind buffers for resultset processing
Setup the bind buffers for resultset processing
*/
*/
my_bool
STDCALL
mysql_bind_result
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
)
my_bool
STDCALL
mysql_
stmt_
bind_result
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
)
{
{
MYSQL_BIND
*
param
,
*
end
;
MYSQL_BIND
*
param
,
*
end
;
ulong
bind_count
;
ulong
bind_count
;
uint
param_count
=
0
;
uint
param_count
=
0
;
DBUG_ENTER
(
"mysql_bind_result"
);
DBUG_ENTER
(
"mysql_
stmt_
bind_result"
);
DBUG_ASSERT
(
stmt
!=
0
);
DBUG_ASSERT
(
stmt
!=
0
);
if
(
!
(
bind_count
=
stmt
->
field_count
)
&&
if
(
!
(
bind_count
=
stmt
->
field_count
)
&&
...
@@ -2965,11 +3006,11 @@ int cli_unbuffered_fetch(MYSQL *mysql, char **row)
...
@@ -2965,11 +3006,11 @@ int cli_unbuffered_fetch(MYSQL *mysql, char **row)
Fetch and return row data to bound buffers, if any
Fetch and return row data to bound buffers, if any
*/
*/
int
STDCALL
mysql_fetch
(
MYSQL_STMT
*
stmt
)
int
STDCALL
mysql_
stmt_
fetch
(
MYSQL_STMT
*
stmt
)
{
{
MYSQL
*
mysql
=
stmt
->
mysql
;
MYSQL
*
mysql
=
stmt
->
mysql
;
uchar
*
row
;
uchar
*
row
;
DBUG_ENTER
(
"mysql_fetch"
);
DBUG_ENTER
(
"mysql_
stmt_
fetch"
);
stmt
->
last_fetched_column
=
0
;
/* reset */
stmt
->
last_fetched_column
=
0
;
/* reset */
if
(
stmt
->
result_buffered
)
/* buffered */
if
(
stmt
->
result_buffered
)
/* buffered */
...
@@ -3025,10 +3066,10 @@ no_data:
...
@@ -3025,10 +3066,10 @@ no_data:
Fetch data for one specified column data
Fetch data for one specified column data
SYNOPSIS
SYNOPSIS
mysql_fetch_column()
mysql_
stmt_
fetch_column()
stmt Prepared statement handler
stmt Prepared statement handler
bind Where data should be placed. Should be filled in as
bind Where data should be placed. Should be filled in as
when calling mysql_bind_result()
when calling mysql_
stmt_
bind_result()
column Column to fetch (first column is 0)
column Column to fetch (first column is 0)
ulong offset Offset in result data (to fetch blob in pieces)
ulong offset Offset in result data (to fetch blob in pieces)
This is normally 0
This is normally 0
...
@@ -3037,11 +3078,11 @@ no_data:
...
@@ -3037,11 +3078,11 @@ no_data:
1 error
1 error
*/
*/
int
STDCALL
mysql_fetch_column
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
,
int
STDCALL
mysql_
stmt_
fetch_column
(
MYSQL_STMT
*
stmt
,
MYSQL_BIND
*
bind
,
uint
column
,
ulong
offset
)
uint
column
,
ulong
offset
)
{
{
MYSQL_BIND
*
param
=
stmt
->
bind
+
column
;
MYSQL_BIND
*
param
=
stmt
->
bind
+
column
;
DBUG_ENTER
(
"mysql_fetch_column"
);
DBUG_ENTER
(
"mysql_
stmt_
fetch_column"
);
if
(
!
stmt
->
current_row
)
if
(
!
stmt
->
current_row
)
goto
no_data
;
goto
no_data
;
...
@@ -3183,7 +3224,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
...
@@ -3183,7 +3224,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
result
->
fields
=
stmt
->
fields
;
result
->
fields
=
stmt
->
fields
;
result
->
field_count
=
stmt
->
field_count
;
result
->
field_count
=
stmt
->
field_count
;
stmt
->
result
=
result
;
stmt
->
result
=
result
;
DBUG_RETURN
(
0
);
/* Data buffered, must be fetched with mysql_fetch() */
DBUG_RETURN
(
0
);
/* Data buffered, must be fetched with mysql_
stmt_
fetch() */
}
}
...
@@ -3275,7 +3316,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt)
...
@@ -3275,7 +3316,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt)
Close the statement handle by freeing all alloced resources
Close the statement handle by freeing all alloced resources
SYNOPSIS
SYNOPSIS
mysql_stmt_
close
()
mysql_stmt_
free_result
()
stmt Statement handle
stmt Statement handle
skip_list Flag to indicate delete from list or not
skip_list Flag to indicate delete from list or not
RETURN VALUES
RETURN VALUES
...
@@ -3313,10 +3354,10 @@ my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
...
@@ -3313,10 +3354,10 @@ my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
}
}
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_
list
,
my_bool
skip_
free
)
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_free
)
{
{
MYSQL
*
mysql
;
MYSQL
*
mysql
;
DBUG_ENTER
(
"
mysql_
stmt_close"
);
DBUG_ENTER
(
"stmt_close"
);
DBUG_ASSERT
(
stmt
!=
0
);
DBUG_ASSERT
(
stmt
!=
0
);
...
@@ -3341,10 +3382,8 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free)
...
@@ -3341,10 +3382,8 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free)
}
}
stmt
->
field_count
=
0
;
stmt
->
field_count
=
0
;
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
if
(
!
skip_list
)
mysql
->
stmts
=
list_delete
(
mysql
->
stmts
,
&
stmt
->
list
);
mysql
->
stmts
=
list_delete
(
mysql
->
stmts
,
&
stmt
->
list
);
mysql
->
status
=
MYSQL_STATUS_READY
;
mysql
->
status
=
MYSQL_STATUS_READY
;
my_free
((
gptr
)
stmt
->
query
,
MYF
(
MY_WME
));
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -3352,7 +3391,7 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free)
...
@@ -3352,7 +3391,7 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free)
my_bool
STDCALL
mysql_stmt_close
(
MYSQL_STMT
*
stmt
)
my_bool
STDCALL
mysql_stmt_close
(
MYSQL_STMT
*
stmt
)
{
{
return
stmt_close
(
stmt
,
0
,
0
);
return
stmt_close
(
stmt
,
0
);
}
}
/*
/*
...
...
sql-common/client.c
View file @
5e54670a
...
@@ -2199,7 +2199,7 @@ void STDCALL mysql_close(MYSQL *mysql)
...
@@ -2199,7 +2199,7 @@ void STDCALL mysql_close(MYSQL *mysql)
for
(
element
=
mysql
->
stmts
;
element
;
element
=
next_element
)
for
(
element
=
mysql
->
stmts
;
element
;
element
=
next_element
)
{
{
next_element
=
element
->
next
;
next_element
=
element
->
next
;
stmt_close
((
MYSQL_STMT
*
)
element
->
data
,
0
,
1
);
stmt_close
((
MYSQL_STMT
*
)
element
->
data
,
1
);
}
}
mysql
->
stmts
=
0
;
mysql
->
stmts
=
0
;
}
}
...
...
tests/client_test.c
View file @
5e54670a
...
@@ -2963,6 +2963,8 @@ static void test_bind_result_ext()
...
@@ -2963,6 +2963,8 @@ static void test_bind_result_ext()
fprintf
(
stdout
,
"
\n
data (double) : %f"
,
d_data
);
fprintf
(
stdout
,
"
\n
data (double) : %f"
,
d_data
);
fprintf
(
stdout
,
"
\n
data (str) : %s(%lu)"
,
szData
,
szLength
);
fprintf
(
stdout
,
"
\n
data (str) : %s(%lu)"
,
szData
,
szLength
);
bData
[
bLength
]
=
'\0'
;
/* bData is binary */
fprintf
(
stdout
,
"
\n
data (bin) : %s(%lu)"
,
bData
,
bLength
);
fprintf
(
stdout
,
"
\n
data (bin) : %s(%lu)"
,
bData
,
bLength
);
...
@@ -3939,6 +3941,7 @@ static void test_prepare_resultset()
...
@@ -3939,6 +3941,7 @@ static void test_prepare_resultset()
result
=
mysql_get_metadata
(
stmt
);
result
=
mysql_get_metadata
(
stmt
);
mytest
(
result
);
mytest
(
result
);
my_print_result_metadata
(
result
);
my_print_result_metadata
(
result
);
mysql_free_result
(
result
);
mysql_stmt_close
(
stmt
);
mysql_stmt_close
(
stmt
);
}
}
...
@@ -4070,17 +4073,17 @@ static void test_stmt_close()
...
@@ -4070,17 +4073,17 @@ static void test_stmt_close()
fprintf
(
stdout
,
"
\n
mysql_close_stmt(1) returned: %d"
,
rc
);
fprintf
(
stdout
,
"
\n
mysql_close_stmt(1) returned: %d"
,
rc
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
mysql_close
(
lmysql
);
/* it should free all open stmts(stmt3, 2 and 1) */
/*
Originally we were going to close all statements automatically in
#if NOT_VALID
mysql_close(). This proved to not work well - users weren't able to
rc
=
mysql_stmt_close
(
stmt3
);
close statements by hand once mysql_close() had been called.
fprintf
(
stdout
,
"
\n
mysql_close_stmt(3) returned: %d"
,
rc
);
Now mysql_close() doesn't free any statements, so this test doesn't
assert
(
rc
==
1
);
serve its original destination any more.
Here we free stmt2 and stmt3 by hande to avoid memory leaks.
rc
=
mysql_stmt_close
(
stmt2
);
*/
fprintf
(
stdout
,
"
\n
mysql_close_stmt(2) returned: %d"
,
rc
);
mysql_stmt_close
(
stmt2
);
assert
(
rc
==
1
);
mysql_stmt_close
(
stmt3
);
#endif
mysql_close
(
lmysql
);
count
=
100
;
count
=
100
;
bind
[
0
].
buffer
=
(
char
*
)
&
count
;
bind
[
0
].
buffer
=
(
char
*
)
&
count
;
...
@@ -4871,7 +4874,10 @@ DROP TABLE IF EXISTS test_multi_tab";
...
@@ -4871,7 +4874,10 @@ DROP TABLE IF EXISTS test_multi_tab";
{
{
fprintf
(
stdout
,
"
\n
Query %d: "
,
count
);
fprintf
(
stdout
,
"
\n
Query %d: "
,
count
);
if
((
result
=
mysql_store_result
(
mysql_local
)))
if
((
result
=
mysql_store_result
(
mysql_local
)))
{
my_process_result_set
(
result
);
my_process_result_set
(
result
);
mysql_free_result
(
result
);
}
else
else
fprintf
(
stdout
,
"OK, %lld row(s) affected, %d warning(s)
\n
"
,
fprintf
(
stdout
,
"OK, %lld row(s) affected, %d warning(s)
\n
"
,
mysql_affected_rows
(
mysql_local
),
mysql_affected_rows
(
mysql_local
),
...
@@ -5768,6 +5774,7 @@ static void test_open_direct()
...
@@ -5768,6 +5774,7 @@ static void test_open_direct()
mytest
(
result
);
mytest
(
result
);
assert
(
0
==
my_process_result_set
(
result
));
assert
(
0
==
my_process_result_set
(
result
));
mysql_free_result
(
result
);
rc
=
mysql_execute
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
mystmt
(
stmt
,
rc
);
...
@@ -5781,6 +5788,7 @@ static void test_open_direct()
...
@@ -5781,6 +5788,7 @@ static void test_open_direct()
mytest
(
result
);
mytest
(
result
);
assert
(
1
==
my_process_result_set
(
result
));
assert
(
1
==
my_process_result_set
(
result
));
mysql_free_result
(
result
);
rc
=
mysql_execute
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
mystmt
(
stmt
,
rc
);
...
@@ -5794,6 +5802,8 @@ static void test_open_direct()
...
@@ -5794,6 +5802,8 @@ static void test_open_direct()
mytest
(
result
);
mytest
(
result
);
assert
(
2
==
my_process_result_set
(
result
));
assert
(
2
==
my_process_result_set
(
result
));
mysql_free_result
(
result
);
mysql_stmt_close
(
stmt
);
mysql_stmt_close
(
stmt
);
/* run a direct query in the middle of a fetch */
/* run a direct query in the middle of a fetch */
...
@@ -6446,6 +6456,7 @@ static void test_prepare_grant()
...
@@ -6446,6 +6456,7 @@ static void test_prepare_grant()
assert
(
4
==
my_stmt_result
(
"SELECT * FROM test_grant"
));
assert
(
4
==
my_stmt_result
(
"SELECT * FROM test_grant"
));
mysql_stmt_close
(
stmt
);
mysql_close
(
lmysql
);
mysql_close
(
lmysql
);
mysql
=
org_mysql
;
mysql
=
org_mysql
;
...
@@ -7552,6 +7563,8 @@ static void test_mem_overun()
...
@@ -7552,6 +7563,8 @@ static void test_mem_overun()
rc
=
mysql_fetch
(
stmt
);
rc
=
mysql_fetch
(
stmt
);
assert
(
rc
==
MYSQL_NO_DATA
);
assert
(
rc
==
MYSQL_NO_DATA
);
mysql_free_result
(
field_res
);
mysql_stmt_close
(
stmt
);
mysql_stmt_close
(
stmt
);
}
}
...
@@ -7876,6 +7889,7 @@ static void test_ts()
...
@@ -7876,6 +7889,7 @@ static void test_ts()
ts
.
hour
=
21
;
ts
.
hour
=
21
;
ts
.
minute
=
07
;
ts
.
minute
=
07
;
ts
.
second
=
46
;
ts
.
second
=
46
;
ts
.
second_part
=
0
;
length
=
(
long
)(
strmov
(
strts
,
"2003-07-12 21:07:46"
)
-
strts
);
length
=
(
long
)(
strmov
(
strts
,
"2003-07-12 21:07:46"
)
-
strts
);
bind
[
0
].
buffer_type
=
MYSQL_TYPE_TIMESTAMP
;
bind
[
0
].
buffer_type
=
MYSQL_TYPE_TIMESTAMP
;
...
@@ -7984,6 +7998,8 @@ static void test_bug1500()
...
@@ -7984,6 +7998,8 @@ static void test_bug1500()
bind
[
0
].
buffer
=
(
char
*
)
int_data
;
bind
[
0
].
buffer
=
(
char
*
)
int_data
;
bind
[
0
].
buffer_type
=
FIELD_TYPE_LONG
;
bind
[
0
].
buffer_type
=
FIELD_TYPE_LONG
;
bind
[
0
].
is_null
=
0
;
bind
[
0
].
is_null
=
0
;
bind
[
0
].
length
=
NULL
;
bind
[
0
].
buffer_length
=
0
;
bind
[
2
]
=
bind
[
1
]
=
bind
[
0
];
bind
[
2
]
=
bind
[
1
]
=
bind
[
0
];
bind
[
1
].
buffer
=
(
char
*
)(
int_data
+
1
);
bind
[
1
].
buffer
=
(
char
*
)(
int_data
+
1
);
bind
[
2
].
buffer
=
(
char
*
)(
int_data
+
2
);
bind
[
2
].
buffer
=
(
char
*
)(
int_data
+
2
);
...
@@ -8422,9 +8438,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
...
@@ -8422,9 +8438,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
static
void
get_options
(
int
argc
,
char
**
argv
)
static
void
get_options
(
int
argc
,
char
**
argv
)
{
{
int
ho_error
;
int
ho_error
;
load_defaults
(
"my"
,
client_test_load_default_groups
,
&
argc
,
&
argv
);
if
((
ho_error
=
handle_options
(
&
argc
,
&
argv
,
client_test_long_options
,
if
((
ho_error
=
handle_options
(
&
argc
,
&
argv
,
client_test_long_options
,
get_one_option
)))
get_one_option
)))
exit
(
ho_error
);
exit
(
ho_error
);
...
@@ -8454,6 +8469,7 @@ static void print_test_output()
...
@@ -8454,6 +8469,7 @@ static void print_test_output()
*********************************************************/
*********************************************************/
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
DEBUGGER_OFF
;
MY_INIT
(
argv
[
0
]);
MY_INIT
(
argv
[
0
]);
load_defaults
(
"my"
,
client_test_load_default_groups
,
&
argc
,
&
argv
);
load_defaults
(
"my"
,
client_test_load_default_groups
,
&
argc
,
&
argv
);
...
@@ -8597,6 +8613,7 @@ int main(int argc, char **argv)
...
@@ -8597,6 +8613,7 @@ int main(int argc, char **argv)
client_disconnect
();
/* disconnect from server */
client_disconnect
();
/* disconnect from server */
free_defaults
(
defaults_argv
);
free_defaults
(
defaults_argv
);
print_test_output
();
print_test_output
();
my_end
(
0
);
return
(
0
);
return
(
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